#include<reg51.h>
#define uchar unsigned char
sbit pluse1=P1^0;
sbit pluse2=P1^1;
uchar t1=0,t2=0;
void t0isr() interrupt 1
{
TH0=(65536-25000)/256;
TL0=(65536-25000)%256;
t1++;
if(t1<15)pluse=1;
else pluse=0;
if(t1>20)t1=0;
}
void t1isr() interrupt 3
{
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
t2++;
if(t2<45)pluse=1;
else pluse=0;
if(t2>150)t2=0;
}
main()
{
TMOD=0x11;
TH0=(65536-25000)/256;
TL0=(65536-25000)%256;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
TR0=1;
TR1=1;
ET0=1;
ET1=1;
EA=1;
pluse1=1;
pluse2=1;
while(1);
}
温馨提示:答案为网友推荐,仅供参考