熱門: 51單片機(jī) | 24小時(shí)必答區(qū) | 單片機(jī)教程 | 單片機(jī)DIY制作 | STM32 | Cortex M3 | 模數(shù)電子 | 電子DIY制作 | 音響/功放 | 拆機(jī)樂園 | Arduino | 嵌入式OS | 程序設(shè)計(jì)
![]() |
發(fā)布時(shí)間: 2019-3-3 09:59
正文摘要:為什么打印出來的時(shí)間這么奇怪呢,求解,謝謝 #include "stm32f10x.h" #include "delay.h" #include "sys.h" #include "oled.h" #include "bmp.h" #include "ds1302.h" #include ... |
代碼邏輯上沒問題。我記得printf是不能傳入太多叁數(shù)。7個(gè)叁數(shù)可能太多了, 試試只傳入秒的數(shù)據(jù)。 |
//從DS302讀出時(shí)鐘數(shù)據(jù) void DS1302_Read_Time(void) { time_buf[1] = DS1302_Read_Byte(ds1302_year_add); //年 time_buf[2] = DS1302_Read_Byte(ds1302_month_add); //月 time_buf[3] = DS1302_Read_Byte(ds1302_date_add); //日 time_buf[4] = DS1302_Read_Byte(ds1302_hr_add); //時(shí) time_buf[5] = DS1302_Read_Byte(ds1302_min_add); //分 time_buf[6] = (DS1302_Read_Byte(ds1302_sec_add))&0x7f; //秒,屏蔽秒的第7位,避免超出59 time_buf[7] = DS1302_Read_Byte(ds1302_day_add); //周 } //DS1302向上層返回時(shí)間數(shù)據(jù) void DS1302_Get_Time(u8 *time) { DS1302_Read_Time(); time[0]=(time_buf[0]>>4); //年 time[1]=(time_buf[0]&0x0f); time[2]=(time_buf[1]>>4); time[3]=(time_buf[1]&0x0f); time[4]=(time_buf[2]>>4); //月 time[5]=(time_buf[2]&0x0f); time[6]=(time_buf[3]>>4); //日 time[7]=(time_buf[3]&0x0f); time[8]=(time_buf[7]&0x07); //星期 time[9]=(time_buf[4]>>4); //時(shí) time[10]=(time_buf[4]&0x0f); time[11]=(time_buf[5]>>4); //分 time[12]=(time_buf[5]&0x0f); time[13]=(time_buf[6]>>4); //秒 time[14]=(time_buf[6]&0x0f); } 更新日期時(shí)間數(shù)組的部分程序有問題。。。。沒這硬件。。。。。調(diào)試原始的數(shù)據(jù)吧,看看具體哪讀的問題 |
Powered by 單片機(jī)教程網(wǎng)