![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
tomi7
Joined: 15 Sep 2004 Posts: 5
|
Problem with RC5 code |
Posted: Wed Jan 05, 2005 1:21 pm |
|
|
I have wrote program for pic12f675 to decode rc5 code.
It works, but decoding rc5 is not correct.
What is wrong ? Can You help me ?
Code: |
#include <12F675.h>
#device adc=8
#use delay(clock=3579545)
#fuses NOWDT,XT, NOCPD, NOPROTECT, NOMCLR, PUT, BROWNOUT
#use rs232(baud=9600,parity=N,xmit=PIN_A0,rcv=PIN_A1,bits=8)
#define IR_SENSOR PIN_A2
#define IR (!input(IR_SENSOR)) //invert bits
int1 flag=0, bit;
int8 code, adress;
int16 i, j, tmp;
int make_8_from_16(long word, short high_low);
#int_EXT
void EXT_isr() {
flag=1; //IR transmit
}
void main() {
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_2);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
ext_int_edge(H_TO_L);
j=0;
while(1)
{
if(flag==1) //half first start bit
{
tmp=0;
delay_us(400); //second half first start bit
for(i=0;i<14;i++) //14 bit (start bits + addres + code)
{
bit=IR;
if (bit==1)
tmp++;
tmp<<=1;
delay_us(1775); //wait 1,776ms for next bit
}
code=0;
adress=0;
code=make_8_from_16(tmp,0);
code&= 0b00111111; //only 6-bit
tmp>>=6; //delete code bits from tmp
adress=make_8_from_16(tmp, 0);
adress&= 0b00011111; //only 5-bit
if(code && adress)
{
printf("a: %x ", adress);
printf("c: %x ", code);
}
flag=0;
enable_interrupts(GLOBAL);
}
}
}
int make_8_from_16(long word, short high_low)
{
#BYTE word0 = word
#BYTE word1 = word + 1
if(high_low == 1)
return(word1);
else
return(word0);
} |
|
|
![](templates/subSilver/images/spacer.gif) |
jds-pic
Joined: 17 Sep 2003 Posts: 205
|
|
Posted: Wed Jan 05, 2005 4:05 pm |
|
|
example of problem please?
i.e.,
what is your input?
what is the expected output?
what is the incorrect output?
jds-pic |
|
![](templates/subSilver/images/spacer.gif) |
tomi7
Joined: 15 Sep 2004 Posts: 5
|
|
Posted: Thu Jan 06, 2005 1:30 pm |
|
|
I use TSOP1738 as IR receiver. Transmition rs-232 works correcly.
Decoding rc5 is wrong, if a press "1" key I get code 30h in place of 01h,
"2" - 28h
"3" - 20h
"4" - 18h
etc... |
|
![](templates/subSilver/images/spacer.gif) |
CMOS
Joined: 09 Oct 2006 Posts: 1
|
|
Posted: Mon Oct 09, 2006 1:56 pm |
|
|
Have you managed to successfully decode RC5 signals? If yes can your please share your code? |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|