CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Manchester Decoding [RC5 Code for Philips Remote Controls]

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
chriss2000
Guest







Manchester Decoding [RC5 Code for Philips Remote Controls]
PostPosted: Fri Jan 17, 2003 12:05 pm     Reply with quote

#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

View user's profile Send private message

Re: Manchester Decoding [RC5 Code for Philips Remote Control
PostPosted: Fri Jan 17, 2003 12:27 pm     Reply with quote

:=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
PostPosted: Fri Jan 17, 2003 1:14 pm     Reply with quote

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
PostPosted: Fri Jan 17, 2003 2:47 pm     Reply with quote

:=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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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