|
h7的HAL 1.8.0版本库 和1.7.0的版本都存在RTC 退出去的情况 当外部晶振不起振会出现在RTC函数出不来的情况
H7的RTC有bug的地方
没改动之前的代码
这个只有H7的1.8.0的版本会有问题 H7的1.7.0的版本没有问题
当晶振不起振的时候 就会死这里不动
- HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef *hrtc)
- {
- uint32_t tickstart;
- HAL_StatusTypeDef status = HAL_OK;
- /* Check if the Initialization mode is set */
- #if defined(RTC_ICSR_INITF)
- if((hrtc->Instance->ICSR & RTC_ICSR_INITF) == 0U)
- {
- /* Set the Initialization mode */
- SET_BIT(hrtc->Instance->ICSR, RTC_ICSR_INIT);
- tickstart = HAL_GetTick();
- /* Wait till RTC is in INIT state and if Time out is reached exit */
- while ((hrtc->Instance->ICSR & RTC_ICSR_INITF) == 0U)
- {
- if((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
- {
- status = HAL_TIMEOUT;
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
- }
- }
- }
- #endif /* RTC_ICSR_INITF */
- #if defined(RTC_ISR_INITF)
- if((hrtc->Instance->ISR & RTC_ISR_INITF) == 0U)
- {
- /* Set the Initialization mode */
- hrtc->Instance->ISR = (uint32_t)RTC_INIT_MASK;
- tickstart = HAL_GetTick();
- /* Wait till RTC is in INIT state and if Time out is reached exit */
- while ((hrtc->Instance->ISR & RTC_ISR_INITF) == 0U)
- {
- if((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
- {
- status = HAL_TIMEOUT;
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
- }
- }
- }
- #endif /* RTC_ISR_INITF */
- return status;
- }
复制代码 这段代码是 H7的1.8.0和1.7.0的版本 都是有问题 会出现意外退不出去的情况
修复之后的代码 这个H7的1.8.0的版本库改动代码参考 H7的1.7.0的版本 自行修改
- HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef *hrtc)
- {
- uint32_t tickstart;
- HAL_StatusTypeDef status = HAL_OK;
- /* Check if the Initialization mode is set */
- #if defined(RTC_ICSR_INITF)
- if((hrtc->Instance->ICSR & RTC_ICSR_INITF) == 0U)
- {
- /* Set the Initialization mode */
- SET_BIT(hrtc->Instance->ICSR, RTC_ICSR_INIT);
- tickstart = HAL_GetTick();
- /* Wait till RTC is in INIT state and if Time out is reached exit */
- while ((hrtc->Instance->ICSR & RTC_ICSR_INITF) == 0U)
- {
- if((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)//固件库这个位置 有bug 退不出来
- {
- status = HAL_TIMEOUT;
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
- break;
- }
- }
- }
- #endif /* RTC_ICSR_INITF */
- #if defined(RTC_ISR_INITF)
- if((hrtc->Instance->ISR & RTC_ISR_INITF) == 0U)
- {
- /* Set the Initialization mode */
- hrtc->Instance->ISR = (uint32_t)RTC_INIT_MASK;
- tickstart = HAL_GetTick();
- /* Wait till RTC is in INIT state and if Time out is reached exit */
- while ((hrtc->Instance->ISR & RTC_ISR_INITF) == 0U)//固件库这个位置 有bug 退不出来
- {
- if((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
- {
- status = HAL_TIMEOUT;
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
- break;
- }
- }
- }
- #endif /* RTC_ISR_INITF */
- return status;
- }
复制代码
|
|