Wednesday 6 March 2013

program to count the external events by using timers in 8051


//program to count the external events by using timers

#include<reg51.h>

sbit event=P3^5;

void main()
{
 event=1;
 TMOD=0x60;//timer1 as coutner in mode2
 TH1=0x00; //count 0
 while(1)
 {
  do
   {
    TR1=1;
                P1=TL1;
   }while(TF1==0);
   TR1=0;
   TF1=0;
 }
}

No comments:

Post a Comment