Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

AT89S52 7 segment multiplexing along with IR - RC5 decoding !!

Status
Not open for further replies.

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.


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;

}
 

Ok, now i will present my whole code here. I can understand that because of use of Timer 0 in all the places, I might be facing the problem, but I could not get the workaround on this.

Code:
#define IR_Signal P3_2

unsigned char cmd=0,val=0;

void delay() //delay of 1.664msec  //delay of 1.658msec 
{ 
    
        TMOD=1; 
        TL0=0x02; 
        TH0=0xFA; 
        TR0=1; 
        while(TF0 == 0); 
        TR0=0; 
        TF0=0; 
    
} 

void delay3() //delay of 2.75 bits = 2.75*1.664msec = 4.57 ms
{ 
    
        TMOD=1; 
        TL0=0x86; 
        TH0=0xEF; 
        TR0=1; 
        while(TF0 == 0); 
        TR0=0; 
        TF0=0; 
    
} 

void InitTimer0(void) //Init Timer 0 for 5 ms multiplexing
{

EA=0;
TMOD = 0x01;
TH0 = 0xEE;
TL0 = 0x00;
TR0 = 1;
ET0 = 1; 
EA = 1; //Enable Global interrupt
}

/*===================================*/

int main()
{

InitTimer0();

    while(1)
    {
        if(IR_signal == 0) // IR signal received on micro-controller pin, collect remaining 11 bits in interval of 1.664 ms
        {

                delay3(); //wait for 2.75 bits = 4.57 ms
        
                cmd=0; 
	        val=0;

                for(i=0; i<12; i++) //collect 11 bits and segregate last 6 command bits
                { 
                    val=(val<<1) | input; 
                    delay(); 
                }
		cmd = val & 0x3F; //command received from Remote control

        }
 
    
    }

return 0;

}

void timer_0ISR () interrupt 1
{

Multiplexing_Logic(); //activating 1 column at a time and sending data to shift registor
	
}
 

Ok, now i will present my whole code here.
Really? I don't see interrupt enable for timer0 set in your code. So how timer interrupt is supposed to work at all? Likewise timer1 is only used in polled mode, so how would it affect timer0 interrupt operation?
 

Really? I don't see interrupt enable for timer0 set in your code. So how timer interrupt is supposed to work at all? Likewise timer1 is only used in polled mode, so how would it affect timer0 interrupt operation?

Interrupt is enabled for Timer 0 as : ET0 = 1;
Timer 1 is not used in Polled mode. Please see my latest code. Timer 0 is used in polled mode.

Regards,
Raj S.
 

Interrupt is enabled for Timer 0 as : ET0 = 1;
Right, I wasn't aware of the meaning of ET0.
Timer 1 is not used in Polled mode. Please see my latest code. Timer 0 is used in polled mode.
O.K. I thought Timer1 would be used for the delay, according to the description in post 1. But you are using timer 0 both for interrupt and delay which can't work.

I see another strange thing in the code, why are you returning from main()?
 

Please find my attached whole code.
Somehow decoding IR signal is not correct and multiplexing not working properly.
Please provide Your suggestion on how to resolve it.

Thanks.
 

Attachments

  • main.txt
    6 KB · Views: 78

in your code MasterDisplay(dataseg); using in main on each timer 1 over flow MasterDisplay(dataseg); is interrupt
by timer ISR() for display use timer 0 and set timer 0 IP high
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top