程序如下,该程序已经在89C51单片机成功测试!但是proteus仿真不了,按照腾讯课堂中操作也无法解决,求大神帮忙?
#include "reg52.h"
#define uchar unsigned char
#define uint unsigned int
uint time_1ms = 0;
uchar key = 0; //if进入条件
/*初始化定时器1,定时1ms*/
void Timer1(void)
{
TMOD = 0x10; //设置定时器模式 0000 1111
TL1 = 0x66; //设置定时初值
TH1 = 0xFC; //设置定时初值
TF1 = 0; //清除TF1标志
ET1 = 1; //定时计数器1溢出中断允许控制位
TR1 = 1; //定时器1开始计时
}
void main(void)
{
P1 = 0xFE; //0xFE=1111 1110
/*初始化定时器0*/
Timer1();
EA = 1; //总中断
while(1)
{
if(key == 1)
{
key = 0;
if(P1 == 0x00) P1 = 0xFF;
P1 = P1 << 1;
}
}
}
void Time1() interrupt 3
{
TL1 = 0x66; //设置定时初值
TH1 = 0xFC; //设置定时初值
time_1ms++;
if(time_1ms >= 2000) //达到2秒
{
key = 1;
time_1ms = 0;
}
}
|