Wednesday 13 March 2013

program for timer interrupt using 8051

/**************** Interrupt program **************************/


/***********Timer interrupt ************************************/

#include<reg51.h>
sbit b = P1^0;
void Timer0(void) interrupt 1
{
     b = ~b;                              //toggling a bit of P1^0 when interrupt occurs
}

void main()
{
       TMOD=0x02;                   //TIMER1 MODE2

       TH0=0x25;

       TR0=1;
       IE=0x82;                          // interrupt initialization for timer 0
       while (1)
       {
                  P0=~P0;                 //toggling port 0
        }

No comments:

Post a Comment