Unsigned char CNT=0;
unsigned char i=0;
TMOD=0 x01;
TH0=0 xb8;
TL0=0 x00;
//EA=1; ET0=1;//time using query, don't drive the interrupt
TR0=1;
While (1)
{
If (TF0==1)
{
TF0=0;
TH0=0 xb8;
TL0=0 x00;
cnt++;
If (CNT & gt;=50)
{
cnt=0;
Sec++;
Why do you even for a second in the past?
CodePudding user response:
You this is not TH0 and TL0 timing time, you can work it out, and then at a certain time, TF0 is set to 1, then adds a CNT and TF0 again set to 0, resetting TH0 and TL0; According to you, this is a second, then TH0=0 xb8; TL0 time=0 x00 to 20 milliseconds, namely 20 milliseconds TF0 from 0 to 1Don't make for a long time, may say no,,,,
CodePudding user response:
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html