Hello
I have written program to set timer interrupt on 8051 microconroller. I want to set interuupt for 50 ms
Fosc = 11.0592Mhz
tick = 12/11.0592M = 1.085069444us = 1.085us
Interrupt time = 60 ms
60,000*1.085= 55299
65536-55299= 10237 =ox27FD
I am setting interrupt for 60 ms. does it means interrupt will generate after 60 ms second,
Does it happen, Led blink after every 60 ms and for 60 ms
I am not sure weather my interrupt calculation is correct or wrong?
I have written program to set timer interrupt on 8051 microconroller. I want to set interuupt for 50 ms
Fosc = 11.0592Mhz
tick = 12/11.0592M = 1.085069444us = 1.085us
Interrupt time = 60 ms
60,000*1.085= 55299
65536-55299= 10237 =ox27FD
Code:
#include<reg51.h>
sbit LED = P1^0;
int main(void)
{
/* Make all ports zero */
P0 = 0x00;
P1 = 0x00;
P2 = 0x00;
P3 = 0x00;
TR0 = 0; //turn Off Timer 0
TF0 = 0; //Clear the interrupt flag
TMOD = 0x01; //Set timer0 in mode 1
TH0 = 0x27; //Load the timer value
TL0 = 0xFD;
ET0 = 1; /* Enable Timer0 interrupts */
EA = 1; /* Global interrupt enable */
TR0 = 1; //turn ON Timer 0
while(1)
{
}
}
void timer(void) interrupt 1
{
LED=~LED; /*toggle LED on interrupt */
TH0=0x48; /* initial values loaded to timer */
TL0=0x01;
}
I am setting interrupt for 60 ms. does it means interrupt will generate after 60 ms second,
Does it happen, Led blink after every 60 ms and for 60 ms
I am not sure weather my interrupt calculation is correct or wrong?