#include
#define uchar unsigned char
#define uint unsigned int
char count1=40,count2=40;
sbit IN_1=P3^4;
sbit IN_2=P3^5;
sbit OUT_1=P3^3;
sbit OUT_2=P3^2;
void main()
{
TMOD = 0x01; //设置定时器模式
TL0 = 0xaf; //设置定时初值
TH0 = 0x3c; //设置定时初值
TF0 = 0; //清除TF0标志
TR0 = 1; //定时器0开始计时
EA = 1;
ET0 = 1;
OUT_1=1;
IN_1=0;
while(1)
{
if((IN_1==1) && (OUT_1==1))
OUT_1=0;
if(count1==0)
{
OUT_1=1;
IN_1=1;
count1=40;
}
}
}
void Time0() interrupt 1
{
TL0 = 0xaf; //定时器手动重装载
TH0 = 0x3c;
if(OUT_1==0)
{
count1--;
}
}
这是我编的程序,但是还是没有实现下降沿触发 |