|
|
View previous topic :: View next topic |
Author |
Message |
chriss2000 Guest
|
Manchester Decoding [RC5 Code for Philips Remote Controls] |
Posted: Fri Jan 17, 2003 12:05 pm |
|
|
#include <16f876.h>
#Device ICD=TRUE
#use delay(clock=4000000)
#bit T0IF=0xB.2
#bit INTF=0xB.1
#use rs232(BAUD=9600, xmit=pin_c6, rcv=pin_c7)
int newbit=0,flag=0,offset=1,i=0;
long count=0,code=0,abtast=75;
#int_ext //allow ext interrupt
isr() //Interrupt Service Routine
{
disable_interrupts(int_ext); //disable interrupt on Pin B0 [until the next signal
set_timer0(0); //Set Timer 0 to zero
flag=1; //Set Interruptflag to 1
}
void main()
{
set_tris_A(0xFF);
set_tris_B(0xFF);
set_tris_C(0x00);
setup_timer_0(RTCC_DIV_16|RTCC_Internal); //Timer 0 Setup, counts up with 62,5kHz
//Teilung: When the counter has the value 1, 16us have left
enable_interrupts(int_ext); //Allow ext Interrupt on Rb0
enable_interrupts(global); //Allow Global Interrupt
ext_int_edge(H_TO_L); //Wait for falling edge--> then jump to Interrupt Service Routine
while(1) //As long as True -->Make Main
{
while(flag=1)
{
if(i<14) //14 Bit Code-->scan 14 times
{
count=get_timer0(); //Get counter time
if(count>=abtast) //If counter time is greater than the value were i want to scan my signal-->scan the Pin A0
{
newbit=input(Pin_A0); //get the bit value of Pin A0
code=code|newbit;
code<<1; //Shift the input values in my integer
abtast=abtast+111; //count up my scan value
}
i++;
}
delay_ms(80); //80ms delay to wait for the beginning of the next signal
enable_interrupts(int_ext); //allow ext Interrupt on Pin B0
flag=0; //Set The Interrupt Flag to Zero to get out of the cycle
abtast=75; //The Timer Value 75 is the same as 1,2 ms and i need that time to scan my bit in the 3/4 bit size
i=0;
}
}
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 10758 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Manchester Decoding [RC5 Code for Philips Remote Control |
Posted: Fri Jan 17, 2003 12:27 pm |
|
|
:=while(flag=1)
:=code<<1;
--------------------------------------------------
Both of the lines above are incorrect.
You must learn to spot these kinds of errors.
I'm struggling with good way to say this:
Programming will not become easy until you
learn to avoid these kinds of errors.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10760 |
|
|
Hans Wedemeyer Guest
|
Re: Manchester Decoding [RC5 Code for Philips Remote Control |
Posted: Fri Jan 17, 2003 1:14 pm |
|
|
I second that.
He has bugged me at home, and I keep telling him about this line of code... I'm sure he just wants someone to write it all for him!
The line of code is commented with //disable interrupt on Pin B0 [until the next signal
Another interrupt is never going to happen !
#int_ext //allow ext interrupt
isr() //Interrupt Service Routine
{
disable_interrupts(int_ext); //disable interrupt on Pin B0 [until the next signal
set_timer0(0); //Set Timer 0 to zero
flag=1; //Set Interruptflag to 1
}
:=:=while(flag=1)
:=
:=:=code<<1;
:=--------------------------------------------------
:=
:=Both of the lines above are incorrect.
:=You must learn to spot these kinds of errors.
:=
:=I'm struggling with good way to say this:
:=Programming will not become easy until you
:=learn to avoid these kinds of errors.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10761 |
|
|
R.J.Hamlett Guest
|
Re: Manchester Decoding [RC5 Code for Philips Remote Control |
Posted: Fri Jan 17, 2003 2:47 pm |
|
|
:=I second that.
:=He has bugged me at home, and I keep telling him about this line of code... I'm sure he just wants someone to write it all for him!
:=
:=The line of code is commented with //disable interrupt on Pin B0 [until the next signal
:=
:=Another interrupt is never going to happen !
:=
Yes. He has used some code I posted, and not added the stuff needed (and mentioned in the comments), to make it work. He needs to clear the interrupt flag, and re-enable the interrupts once the last bit of the current character is received.
Combined with the syntax errors it makes sure the code won't work...
Best Wishes
:=#int_ext //allow ext interrupt
:=isr() //Interrupt Service Routine
:={
:=disable_interrupts(int_ext); //disable interrupt on Pin B0 [until the next signal
:=set_timer0(0); //Set Timer 0 to zero
:=flag=1; //Set Interruptflag to 1
:=}
:=:=:=while(flag=1)
:=:=
:=:=:=code<<1;
:=:=--------------------------------------------------
:=:=
:=:=Both of the lines above are incorrect.
:=:=You must learn to spot these kinds of errors.
:=:=
:=:=I'm struggling with good way to say this:
:=:=Programming will not become easy until you
:=:=learn to avoid these kinds of errors.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10762 |
|
|
|
|
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
|