初级会员

- 积分
- 197
- 金钱
- 197
- 注册时间
- 2013-10-31
- 在线时间
- 26 小时
|

楼主 |
发表于 2017-10-20 09:25:13
|
显示全部楼层
我是在程序里先设置时间 然后再屏蔽掉。代码如下:[mw_shl_code=c,true]#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "rtc.h"
int main(void)
{
RTC_TimeTypeDef RTC_TimeStruct;
RTC_DateTypeDef RTC_DateStruct;
u8 tbuf[40];
HAL_Init(); //3õê¼»ˉHAL¿a
Stm32_Clock_Init(360,25,2,8); //éèÖÃê±Öó,180Mhz
delay_init(180); //3õê¼»ˉÑóê±oˉêy
uart_init(115200); //3õê¼»ˉUSART
RTC_Init(); //3õê¼»ˉRTC
RTC_Set_WakeUp(RTC_WAKEUPCLOCK_CK_SPRE_16BITS,0); //ÅäÖÃWAKE UPÖD¶Ï,1ÃëÖóÖD¶Ïò»′Î
// RTC_Set_Time(11,59,40,RTC_HOURFORMAT12_AM); //RTCê±¼äéèÖÃ
// RTC_Set_Date(17,10,19,4); //RTCèÕÆúéèÖÃ
while(1)
{
delay_ms(1000);
HAL_RTC_GetTime(&RTC_Handler,&RTC_TimeStruct,RTC_FORMAT_BIN);
sprintf((char*)tbuf,"Time:%02d:%02d:%02d",RTC_TimeStruct.Hours,RTC_TimeStruct.Minutes,RTC_TimeStruct.Seconds);
printf("%s\r\n", tbuf);
HAL_RTC_GetDate(&RTC_Handler,&RTC_DateStruct,RTC_FORMAT_BIN);
sprintf((char*)tbuf,"Date:20%02d-%02d-%02d",RTC_DateStruct.Year,RTC_DateStruct.Month,RTC_DateStruct.Date);
printf("%s\r\n", tbuf);
sprintf((char*)tbuf,"Week:%d",RTC_DateStruct.WeekDay);
printf("%s\r\n\r\n", tbuf);
}
}
[/mw_shl_code]
只通过串口打印时间日期。但是会出现上述问题。
|
|