STM32F103RCT6的RTC和PC13,也是HAL庫,最後也是在RTC初始化以後,添加下面的函數PC13才正常工做。html
HAL_PWR_EnableBkUpAccess(); __HAL_RCC_BKP_CLK_ENABLE(); BKP->RTCCR&=~BKP_RTCCR_ASOE;
https://www.amobbs.com/thread-5717364-1-1.htmlide
HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);//設置時間戳 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin);//設置時間戳並開中斷 HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc);//關閉時間戳 HAL_StatusTypeDef HAL_RTCEx_SetInternalTimeStamp(RTC_HandleTypeDef *hrtc);//設置內部時間戳 HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTimeStamp(RTC_HandleTypeDef *hrtc);//關閉內部時間戳 HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format);//獲取當前記錄的時間戳