Hi all
I need help to understand 8051 timer interrupt. I have visited on some links and I find below code for 8051 timer interrupt. But I don't understand logically how does 8051 timer interrupt work. I am trying understand below code
My attempt : at the beginning of main section, initially LED will be OFF, Time 0 and Timer 0 Interrupt will be SET and we need to Enable global interrupts
How does 8051 timer interrupt work .logically and programmatically?
I need help to understand 8051 timer interrupt. I have visited on some links and I find below code for 8051 timer interrupt. But I don't understand logically how does 8051 timer interrupt work. I am trying understand below code
C:
#include<reg51.h>
sbit LED = P1^0; //LED connected to P1.0
Void main()
{
TMOD = 0x01; // mode1 of Timer0
TH0 = 0xFC; // initial values loaded to timer
TL0 = 0x66;
IE = 0x82; // enable interrupt
TR0 = 1; //start timer
while(1); // do nothing
}
void timer(void) interrupt 1 //interrupt no. 1 for Timer 0
{
led=~led; //toggle LED on interrupt
TH0=0xFC; // initial values loaded to timer
TL0=0x66;
}
C:
main( )
{
LED = off // Set initial state (off) for LED
TR0 = 1; // Set the Timer 0
ET0 = 1; // Set Timer 0 Interrupt
EA = 1; // Enable global interrupts on..
}
void timer (void) __interrupt (1)
{
}
Last edited: