#include
#include
#define uchar unsigned char
#define uint unsigned int
void main()
{
uchar T_Count = 0;
P0 = 0xfe;
P2 = 0xfe;
TMOD = 0x10;//定时器1方式1
TH1 = (65535-50000)/256;//定时50000us=50ms
TL1 = (65535-50000)%256;
TR1 = 1;//启动定时器1
while(1)
{
if(TF1== 1)//查询方式定时时间到后TF1=1
{
TF1 = 0;
TH1 = (65535-50000)/256;
TL1 = (65535-50000)%256;
if(++T_Count == 20)//50ms*20=1000ms
{
P0 = _crol_(P0,1);
P2 = _crol_(P2,1);
T_Count = 0;
}
}
}
}