我想实现的是led灯循环亮一秒熄灭一秒,但是我的代码没有报错,我也没检查出错误😢。它是过很久亮而且亮一会又灭一会那种。这个根本不止1s啊,求友友帮助🥰
#include <REGX52.H>
void Timer0_Init()
{
TMOD &= 0xF0;
TMOD |= 0x01;
TL0 = 0xCD;
TH0 = 0xD4;
TF0 = 0;
TR0 = 1;
ET0=1;
EA=1;
PT0=0;
}
void main()
{
Timer0_Init();
while(1)
{
}
}
unsigned int T0Count;
void Timer0_Routine() interrupt 1
{
TL0 = 0xCD;
TH0 = 0xD4;
T0Count++;
if(T0Count>=1000)
{
T0Count=0;
P2_0=~P2_0;
}
}