我使用的是金沙滩51单片机开发板,stc89c52的单片机,
以下是我的程序:
#include<reg52.h>
sbit LED = P0^0;
sbit ADDR0 = P1^0;
sbit ADDR1 = P1^1;
sbit ADDR2 = P1^2;
sbit ADDR3 = P1^3;
sbit ENLED = P1^4; void main ()
{
unsigned char cnt = 0;
ENLED = 0;
ADDR3 = 1;
ADDR2 = 1;
ADDR1 = 1;
ADDR0 = 1;
TMOD = 0x01;
TH0 = 0xB8;
TL0 = 0x00;
TR0 = 1;
while(1)
{
if(TF0 == 1)
{
TF0 = 0;
TH0 = 0xB8;
TL0 = 0x00;
cnt++;
if(cnt >= 50)
{
cnt = 0;
LED = ~LED;
}
}
}
}
我的开发板显示如下:
小灯没坏,可以实现用for(i=1;i<=10000;i++)进行延时的流水灯,
不知道哪里出问题了,求大家指导,在线等:
|