rajesh279
Junior Member level 3
- Joined
- Jun 11, 2009
- Messages
- 29
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,521
Hello All,
I am currently trying to execute logic for 7 segment multiplexing along with RC5 decoding from IR TSOP1738 sensor.
The 7 segment multiplexing is taken care by Timer 0 ISR (10 ms duration) whereas RC5 decoding is done using Timer 1 delay routines.
The approach is shown in below code. The problem I am facing is, whenever I press any remote button, the multiplexing get disturbed while decoding IR signal.
Overall, I would like to understand how both multiplexing and IR decoding can be done together without disturbing each other, as both are time dependent event.
I am currently trying to execute logic for 7 segment multiplexing along with RC5 decoding from IR TSOP1738 sensor.
The 7 segment multiplexing is taken care by Timer 0 ISR (10 ms duration) whereas RC5 decoding is done using Timer 1 delay routines.
The approach is shown in below code. The problem I am facing is, whenever I press any remote button, the multiplexing get disturbed while decoding IR signal.
Overall, I would like to understand how both multiplexing and IR decoding can be done together without disturbing each other, as both are time dependent event.
Code:
#define IR_Signal P3_2
void delay() //delay of 1.664msec
{
TMOD=1;
TL1=0x02;
TH1=0xFA;
TR1=1;
while(TF1 == 0);
TR1=0;
TF1=0;
}
void delay3() //delay of 2.75 bits = 2.75*1.664msec = 4.57 ms
{
TMOD=1;
TL1=0x86;
TH1=0xEF;
TR1=1;
while(TF1 == 0);
TR1=0;
TF1=0;
}
void InitTimer0(void) //Init Timer 0 for 10 ms multiplexing
{
EA=0;
TMOD = 0x01;
TH0 = 0xDC;//
TL0 = 0x00;
TR0 = 1;
ET0 = 1;
EA = 1; //Enable Global interrupt
}
/*===================================*/
int main()
{
InitTimer0();
if(IR_signal == 0) // IR signal received on micro-controller pin, collect remaining 11 bits in interval of 1.664 ms
{
cmd=0;
val=0;
for(i=0; i<12; i++)
{
val=(val<<1) | input;
delay();
}
cmd = val & 0x3F; //command received from Remote control
}
return 0;
}