#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar tt0,tt1,num,aa;
sbit feng=P2^3;
uchar code table[]={0x01,0x02,0x03,
0x04,0x05,0x06,0x07,0x08,0x09,0x50};
void init()
{
TMOD=0x11;
TH1=(65535-50000)/256;
TL1=(65535-50000)%256;
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
EA=1;
ET0=1;
ET1=1;
TR0=1;
TR1=1;
}
void main()
{
init();
while(1)
{
if(tt1>3)
{
tt1=0;
for(num=0;num<8;num++)
aa=table[num];
if(num==8)
num=0;
}
else
{
if(tt0==aa)
feng=0;
if(tt0==2*aa)
{
tt0=0;
feng=1;
}
}
}
}
void timer0() interrupt 1
{
TH0=(65535-5000)/256;
TL0=(65535-5000)%256;
tt0++;
}
void timer1() interrupt 3
{
TH1=(65535-50000)/256;
TL1=(65535-50000)%256;
tt1++;
} |