
#include<reg51.h>
sbit LED=P2^0;
unsigned char count;
char cputick;
void timer_isr(void) interrupt 1 using 1
{
	TH0 |= 0xdc;	      // 10 ms @ 11.059200 Mhz
	cputick++;
} 
void main(void)
{	
    TMOD = 0x01; 	     // timer0 mode 1
    EA = ET0 = TR0 = LED =1; // enable timer0 interrupt, start timer
    count = 0;
    while(1)
    {
     while(!cputick);  	     // run following tasks every 10ms
     cputick = 0;
     if (++count > 99)       // 100 * 10ms = 1 second
     {
      count = 0;	     // reset for next cycle
      LED=~(LED);	     // LED on/off
     }
    } 
}

