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 CCS Technical Support

Need help with Sony IR code

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



Joined: 14 May 2009
Posts: 1
Location: fgf

View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number

Need help with Sony IR code
PostPosted: Thu May 14, 2009 1:33 pm     Reply with quote

I have been written a code to decode SONY IR to turn on or turn off lights. But something was wrong. Please help me. Thanks.
Code:
#include <16f877A.h>
#use delay(clock=4000000)
#fuses HS,NOWDT, NOPROTECT
#use fast_IO(B)

#byte portB=0x06
#bit B0=portB.0
#bit B1=portB.1
#bit B2=portB.2
#bit B3=portB.3
#bit B4=portB.4
#bit B5=portB.5
#bit B6=portB.6
#bit B7=portB.7

int16 CCP1Value;
BOOLEAN CCP1Captured;

#int_CCP1
void ngat()

 CCP1value=CCP_1;
 set_timer1(0);
 CCP1captured=TRUE;
}

void init_CCP1()
{
setup_CCP1(CCP_CAPTURE_RE);
setup_timer_1(T1_EXTERNAL|T1_DIV_BY_8);
CCP1captured=TRUE;
CCP1value=0;
enable_interrupts(int_CCP1);
enable_interrupts(global);
}

float dochuky()
{
float T;
init_CCP1();
if(CCP1captured==TRUE)
{   T=(CCP1value)*8e-6;
CCP1captured=FALSE;
}
return T;
}

void main()
{
int8 A;
int i;
float T;
while(TRUE)
  {
    A=0b00000010;//lam nhu the de vi ma bit cua phim 1 la 0h
    for(i=0;i<8;i++)
    {
    T=dochuky();
    if(T<=1300&&T>=1100) {A=A+0;}
    else if(T<=1900&&T>=1700) A=A+0b00000001;
    A=A>>1;
    }
       
    if(A==0b00000000) B0=!B0;
   else if(A==0b00000001) B1=!B1;
   else if(A==0b00000010) B2=!B2;
   else if(A==0b00000011) B3=!B3;
   else if(A==0b00000100) B4=!B4;
   else if(A==0b00000101) B5=!B5;
   else if(A==0b00000110) B6=!B6;
   else if(A==0b00000111) B7=!B7;
  }
}

_________________
fafagh
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