#include <reg51.h>
#define uint unsigned int
#define uchar unsigned char
#define LED P1
#define count 50000
#define TH_M1 (65636-count)/256
#define TL_M1 (65636-count)%256
void main()
{
uchar i=0,j=0x01;
TMOD &= 0xF0;
TMOD |= 0x01;
TH0 = TH_M1;
TL0 = TL_M1;
TF0 = 0;
TR0 = 1;
LED=~j;
while(1)
{
if(TF0==1)
{
TF0=0;
i++;
if(i==20)
{
i=0;
j<<=1;
if(j==0)
j=0x01;
LED=~j;
}
}
}
} |