cancel
Showing results for 
Search instead for 
Did you mean: 

Case of Infinite loop of RTC

Elik Livnat
Associate II

There is a situation with RTC of RTC get into infinite loop in file stm32f7xx_hal.c.

In the function HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef* hrtc)

lines

 while((hrtc->Instance->ISR & RTC_ISR_INITF) == (uint32_t)RESET)  {

 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)

   {   

    return HAL_TIMEOUT;

   }

  }

We encounter a situation that LSE is configured and works and RTC got into infinite loop in this while loop.

HAL_GetTick did not produce any ticks due to intermittent HW error, and it cause infinite loop.

Anyway, did STM think about the meaning that a device stop working due that this loop.

Programming in while loop with out any option to opt out is wrong.

There is easy solution but this is HAL driver which we would not like to change.

Any other solution from STM?

Thank you.

Elik

2 REPLIES 2

> Any other solution from STM?

I am not ST, but yes, of course, you can simply not use the function using this loop and write your own.

The primary concern here is, however, this:

> We encounter a situation that LSE is configured and works and RTC got into infinite loop in this while loop.

INITF flag gets set by a synchronizer driven by RTCCLK, so the only way how it won't get set is, that you don't have RTCCLK. In other words, either your "LSE is configured" piece of program is incorrect and does not guarantee LSE=>RTCCLK running, or your hardware is faulty and LSE is unstable and stops when you get to that loop. Get sorted out that first; you can't write any reasonable program with unreliable hardware.

JW

Elik Livnat
Associate II

Thank you JW,

In my case the LSE=>RTCCLK is fine and LSE is not faulty.

My point is that the HAL driver code is a bad programming practice, especially for system that the RTC is not crucial and should not stop the whole system even if LSE becomes faulty.

EL