我用串口显示秒,部分出现了乱码,是什么原因,开始时间为0秒 unsigned int ReadTime() //接收并且转换为十进制 { dat = ReadDs1302(0x81) ; damp = (int)dat / 16*10 + (int)dat %16; return damp; } void main() { uart_init(); SetTime(); //设置开始时间 while(1) { sec = ReadTime(); printf("%d ",sec); Delay100ms(10); } } 例如: 1 0 3 0 1 2 7 0 1 0 1 0 3 0 1 2 7 8 9 0 1 0 3 0 1 2 7 0 1 10 11 8 13 8 9 10 17 18 19 0 1 0 |
无事再来顶一下 |
本程序已实测无BUG,若温度不显示,要按你的晶振来调DS18B20读写部分的延时,本程序使用STC12C5A60S2单片机和6M晶振实测 |