#include
typedef unsigned char uchar;
sbit signal=P3^0;
uchar counter;
void main(void)
{
TR0=0; //制止T0
TMOD=0x11; //T0和T1均挑选工作方式1,16位守时器
TH0=-1000/256; //守时时刻为50ms
TL0=-1000%256;
signal=0; //开端时输出为低电平
counter=0; //初始化T1的中止次数为0
EA=1; //使能CPU中止
ET0=1; //使能T0溢出中止
ET1=1; //使能T1溢出中止
TR0=1; //T0开端运转,留意,T1不能现在运转
while(1) //无限循环
{}
}
void isr_t0(void) interrupt 1 //T0中止服务函数
{
TH0=-50000/256; //装守时器,守时时刻为50ms
TL0=-50000%256;
counter++; //中止次数
if(counter==2) //若已中止两次,阐明现已曩昔100ms
{
counter=0; //中止次数归零
signal=1; //发生矩形波中的高电平
TR1=1; //开端计数T1
}
}
//***********T1中止函数******
void isr_t1(void) interrupt 3
{
signal=0; //矩形波中的低adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=17&is_app=0&jk=7a0d3925e7099c8b&k=%B5%E7%C6%BD&k0=%B5%E7%C6%BD&kdi0=0&luki=1&n=10&p=baidu&q=98059059_cpr&rb=0&rs=1&seller_id=1&sid=8b9c09e725390d7a&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1831118&u=http%3A%2F%2Fwww%2E51hei%2Ecom%2Fmcu%2F1968%2Ehtml&urlid=0″ id=”0_nwl” mpid=”0″ target=”_blank”>电平
TR0=0; //制止T1计数,等候T0将其唤醒
TH1=-25000/256; //25ms中止初值
TL1=-25000%256;
}