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

problem with RC5 remote code...

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



Joined: 09 Aug 2007
Posts: 82
Location: TN, India

View user's profile Send private message Send e-mail

problem with RC5 remote code...
PostPosted: Wed May 28, 2008 11:43 am     Reply with quote

hai friends,

i try below code for decodes the RC5 remote code and send to rs232 port.. when press remote button, i don't got any data from rs232 port. please check the code and give the solution for problem.


Code:
#include <16F877a.h>
#use delay(clock=20000000)
#fuses NOWDT,HS, NOPUT, NOPROTECT, BROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG

#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
int1 get_RC5(void);


#define IR_INPUT PIN_B0         // the infrared receiver has to be connected to an
                                // interrupt-pin!

#define IR_STATUS (!input(IR_INPUT))  // invert the signal from the infrared receiver



typedef struct
{
int8 data[2];
int8 state;
} rc5_struct;
rc5_struct rc5;

#int_EXT
EXT_isr()
{
   get_RC5();
}

int1 get_RC5(void)
{
   int16 tmp,t;
   int i;
   int1 inp;

   set_timer1(0);
   while(IR_STATUS==1);
   t=get_timer1();

   if ((t<400) || (t>800)) return 0;   // no RC5 code, abort decoding

   for (i=0;i<13;i++)
   {
      inp=IR_STATUS;
      set_timer1(0);

      while (IR_STATUS==inp)
      {
         t=get_timer1();
         if (t>800) return 0;   // no RC5 code, abort decoding
      }

      tmp<<=1;

      if (inp==0) tmp++;

      set_timer1(0);
      while (get_timer1()<776);  // a simple delay would work here as well
   }

   tmp=tmp | 0x3000;
   tmp=tmp & 0x37ff; // cut off togglebit

   rc5.data[0]=tmp & 0xff;  // device address
   tmp>>=8;
   rc5.data[1]=tmp & 0xff;  // command code

   rc5.state = 1;

   disable_interrupts(INT_EXT);
write_eeprom(0,rc5.data[0]);
          write_eeprom(1,rc5.data[1]);
   return 1;
}




void main()
{
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   enable_interrupts(INT_EXT);
   enable_interrupts(GLOBAL);
write_eeprom(0,0Xff);
write_eeprom(1,0Xff);
   rc5.state = 0;
output_high(pin_b1);
   while(1)
   {
      if(rc5.state==1)  // did we receive a valid RC5 - command?
      {

printf("data[0] = %d ",rc5.data[0]);
printf("data[1] = %d ",rc5.data[1]);
         output_low(pin_b1);
         
         rc5.state = 0;
         enable_interrupts(INT_EXT);
      }

   }


}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 28, 2008 11:59 am     Reply with quote

You copied that code directly from this website:
http://home.tu-clausthal.de/~dpor/files/rc5.c

At the bottom of his web page, he says this:
Quote:
If you have any questions, just drop me a mail!

http://home.tu-clausthal.de/~dpor/rc5dekoder_eng.html
Why don't you do that ?
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