cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_SYSTICK_Config() hangs on HAL_Init()

MDaub.1
Associate III

I had a working project in STM32CubeIDE when "suddenly" HAL_Delay() did no longer properly work (with the stepper motor shield). During investigation I found that HAL_Delay was basically hanging forever. No, without knowingly changing something, my code even hangs reproducibly in the very first line of code when calling HAL_Init().

HAL_Init() is calling HAL_InitTick() and the code hangs on that first line HAL_SYSTICK_Config().

__weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
{
  /* Configure the SysTick to have interrupt in 1ms time basis*/
  if (HAL_SYSTICK_Config(SystemCoreClock / (1000U / uwTickFreq)) > 0U)    <<<<<---------
  {
    return HAL_ERROR;
  }
 
  /* Configure the SysTick IRQ priority */
  if (TickPriority < (1UL << __NVIC_PRIO_BITS))
  {

What I don't understand is - WHY?

SystemCoreClock == 16000000

uwTickFreq == HAL_TICK_FREQ_1KHZ

HAL_SYSTICK_Config only consists of a call to SysTick_Config(TicksNumb) but even when I set a breakpoint on that line it is never called. When I interrupt the program the debugger tells me he's still on the line of HAL_SYSTICK_Config()

What could be the reason? I am literally tearing my hair out :(

All the CubeMX related stuff is after that, all the clock config is after that, interrupts are not in use as far as I can see - so what could be the reason for the code hanging there?

I restarted STMCubeIDE, cleaned and rebuild the project etc. etc. but to no avail.

I can of course simple start a new project but I would like to understand what is causing the problem.

I single stepped in the debugger and the CPU is stopping on that instruction "mov r1,r3" I cannot surpass that line?

0693W00000AP5kEQAT.png

0 REPLIES 0