Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/18/05 12:30
Read: times


 
#99643 - This works for me.
Responding to: ???'s previous message
Hello Suyash,

This will blink an LED on/off every second.

Regards,

Charles Bannister
#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
     }
    } 
}



List of 4 messages in thread
TopicAuthorDate
my timer dosen't work.            01/01/70 00:00      
   Missing brackets            01/01/70 00:00      
   Critical error            01/01/70 00:00      
   This works for me.            01/01/70 00:00      

Back to Subject List