小白剛學用定時寫了個1秒閃燈沒問題,可是寫流水單就出現問題了,圖片是程序運行狀態,麻煩大家指教一下
單片機源程序如下:
#include "reg52.h"
#include "intrins.h"
#define uchar unsigned char
#define uint unsigned int
void main()
{
uint cnt;
uchar sec=0;
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;
P0=_crol_(sec,1);
sec++;
if(sec>=8)
{
sec=0;
}
}
}
}
}
|