避免在定时中断中打印

This commit is contained in:
fengbh 2024-01-15 21:03:15 +08:00
parent 265481c1d6
commit 3334d7896c

View File

@ -16,7 +16,7 @@
#include "time0.h"
int HH=0, MM=0, SS=0;
int temp_value=0;
int send_tmp = 0;
/*******************************************************************************
* : main
* :
@ -27,6 +27,7 @@ void main(void)
{
u8 i=0;
u8 temp_buf[5];
int temp_value = 0;
uart_init(0XFA);//波特率为9600
ds18b20_init();//初始化DS18B20
@ -53,7 +54,10 @@ void main(void)
smg_display(temp_buf,4);
// 串口打印
// printf("temp = %.1f\n", temp_value/10.0);
if(send_tmp == 1) {
send_tmp = 0;
printf("%02d:%02d:%02d temp = %.1f\r\n", HH, MM, SS, temp_value/10.0);
}
}
}
@ -85,7 +89,7 @@ void time0(void) __interrupt (1) //定时器0中断函数
if(i==1000)
{
i=0;
LED1=!LED1;
send_tmp = 1;
SS ++;
if (SS == 60){
@ -96,6 +100,5 @@ void time0(void) __interrupt (1) //定时器0中断函数
MM = 0;
HH ++;
}
printf("%02d:%02d:%02d temp = %.1f\r\n", HH, MM, SS, temp_value/10.0);
}
}