唉,板子硬件问题,换了块板就好了!浪费论坛资源,不知道怎么删帖 void set_RTCtime(u8 hour,u8 min,u8 sec) { RTC_TimeTypeDef RTC_TimeStructure; RTC_TimeStructure.RTC_H12 = RTC_H12_AM; RTC_TimeStructure.RTC_Hours = hour; RTC_TimeStructure.RTC_Minutes = min; RTC_TimeStructure.RTC_Seconds = sec; RTC_SetTime(RTC_Format_BCD,&RTC_TimeStructure); } void set_RTCdate(u8 year,u8 month,u8 day,u8 week) {//Set the date RTC_DateTypeDef RTC_DateStructure; RTC_DateStructure.RTC_Year = year; RTC_DateStructure.RTC_Month = month; RTC_DateStructure.RTC_Date = day; RTC_DateStructure.RTC_WeekDay= week; RTC_SetDate(RTC_Format_BCD,&RTC_DateStructure); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 初始化完后,每秒调用以下函数一次 void RTC_TimeShow(void) { RTC_TimeTypeDef RTC_TimeStructure; RTC_DateTypeDef RTC_DateStructure; RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure); //Get the current Date //Display date Format : y-m-d printf("%0.2d-%0.2d-%0.2d ",RTC_DateStructure.RTC_Year, RTC_DateStructure.RTC_Month, RTC_DateStructure.RTC_Date); xDelay(); xDelay(); xDelay(); RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure); //Get the current Time //Display time Format : hh:mm:ss printf("%0.2d:%0.2d:%0.2d\r\n",RTC_TimeStructure.RTC_Hours, RTC_TimeStructure.RTC_Minutes, RTC_TimeStructure.RTC_Seconds); xDelay(); xDelay(); xDelay(); } 请高手指点一下,为何我配置过RTC后,读出后通过串口打印的时间是这样的?谢谢 |
换了块板就好了! |