STC89C52RC 定时器0控制高电平,定时器1控制周期,两个按键分别增加t1和t2值
但下载到
芯片内无反应,求解
#include<reg52.h> //doesnt work
typedef unsigned char uchar;
sbit V_OUT=P1^0;
sbit KEY1=P3^4;
sbit KEY2=P3^5;
int t1,t2;
void
timer0_1_init(void)
{
TMOD=0x11;
TH0=0xff;
TL0=0xff;
TH1=0xff;
TL1=0xff;
ET0=1;
ET1=1;
TR0=1;
EA=1;
}
void timer0()interrupt 1 using 1
{
V_OUT=0;
TH1=t1/10;
TL0=t1%10;
TR0=0;
TR1=1;
}
void timer1()interrupt 3 using 2
{
V_OUT=1;
TH1=t2/10;
TL1=t2%10;
TR1=0;
TR0=1;
}
void main(void)
{
t1=56320,t2=t1;
while(1)
{
KEY1=1;
if(KEY1==0)
{
t1+=10;
if(t1<56320)t1=56320;
}
KEY2=1;
if(KEY2==0)
{
t2++;
if(t2<56320)t2=56320;
}
}
}
void scan()
if(k1=1)
delay 10ms
if(k1=1)
{
...
}
一周热门 更多>