cancel
Showing results for 
Search instead for 
Did you mean: 

Infinite loop in HAL_RCC_OscConfig - STM32G4 ?

newbie_stm32
Associate III

Hi Community,

I am working on a project with a custom board that uses both HSE (24MHz) and LSE (32.768KHz) clock sources. TIM6 is used as a time base source because SysTick is used by the RTOS. When running a debug session I can see that it is going into an infinite loop at the following code in the HAL library.

 

/* Wait till LSE is ready */
while (READ_BIT(RCC->BDCR, RCC_BDCR_LSERDY) == 0U)
{
  if((HAL_GetTick() - tickstart) > RCC_LSE_TIMEOUT_VALUE)
  {
    return HAL_TIMEOUT;
  }
}

 

After a closer look, it is found that HAL_GetTick is returning 0 every time because of which it went into an infinite loop but it should not be zero at this point because it is initialized in the HAL_Init with HAL_InitTick which in turn runs TIM6 ISR and should start updating the tick.

 

Why is that so?

PS: The configuration and code generation is done using STM32CubeIDE. This code ran effectively on a Nucleo Board. But not running on a custom board.

10 REPLIES 10

Hi,

set the LSE drive to high drive , check then in program.

Be aware if check with a scope: with 10:1 (10Mohm) probe it might be possible, to see the 32kHz oscillation, but you might stop it, just because connecting the probe !

And the crystal + surrounding area has to be clean, no solder/flux remains there; clean with aceton or isopropanol, if not sure about "clean" .

+ check Vbat : > 3.0 V ?

If you feel a post has answered your question, please click "Accept as Solution".