一、寄存器配置的错误
#include <REGX52.H>
void Timer0Init(void) //1毫秒@11.0592MHz
{
TMOD &= 0xf0;
TMOD |= 0x01;
TL0 = 0x18;
TH0 = 0xfc;
TF0 = 0;
TR0 = 1;
ET0 = 1;
EA = 1;
PT0 = 0;
}
void main()
{
Timer0Init();
while (1)
{
}
}
void ok_no() interrupt 1
{
static unsigned int Tocount;
TL0 = 0x18;
TH0 = 0xfc;
Tocount++;
if (Tocount>=1000)
{
Tocount=0;
P2=~P2;
}
}