STM32H745XI – HAL_Init() hangs in HAL_Delay() during debug
Hi,
I am working on a custom board using STM32H745XI MCU.
I am facing an issue on one particular board.
The same source code works correctly on our other boards with the same MCU and hardware. On the problematic board:
-
The firmware can be programmed successfully using STM32CubeProgrammer.
-
After programming, the firmware runs normally.
-
But when I debug the same firmware from STM32CubeIDE using ST-LINK, execution reaches
Reset_Handlerand thenmain(). -
HAL_Init()is entered, but it does not return. -
After debugging
HAL_Init(), I found that execution is actually hanging at:
HAL_Delay(1000);
inside HAL_Init().
The relevant flow is:
Reset_Handler
↓
main()
↓
HAL_Init()
↓
HAL_InitTick()
↓
HAL_MspInit()
↓
HAL_Delay(1000)
↓
HANG
↓
SystemClock_Config() ← never reached
My understanding of the problem
HAL_Delay() depends on the HAL tick counter (uwTick) being incremented periodically by the SysTick interrupt.
Normally the flow should be:
SysTick interrupt
↓
SysTick_Handler()
↓
HAL_IncTick()
↓
uwTick++
↓
HAL_Delay() detects elapsed time
↓
HAL_Delay(1000) returns
If the SysTick interrupt is not occurring, or HAL_IncTick() is not being executed, uwTick will not increase and HAL_Delay(1000) can remain in its waiting loop indefinitely.
This is happening before SystemClock_Config(), so the system is still using the default clock configuration after reset.
I am trying to understand why this happens only during debugging on this particular board, while the same firmware runs correctly when programmed using CubeProgrammer and also works correctly on other identical boards.
Could this be related to:
-
SysTick interrupt not being generated during debug
-
ST-LINK/debug reset behavior
-
Interrupt configuration or priority
-
Cortex-M7 startup/debug state
-
Option Bytes or boot configuration
-
Any STM32H745-specific debug behavior
Any suggestions on what could cause HAL_Delay() to hang at this stage would be appreciated.
