My code stuck at HAL_InitTick() at the beginning of the code
I am programming my custom board with STM32G491CEU6 and STM32CubeMX 6.5.0.
The code is generated with STM32Cube_FW_G4 v1.5.1 firmware.
Steps to reproduce:
- Select 'access to MCU selector' after opening STM32CubeMX.
- Select STM32G491CEU6 and create the project.
- In System Core->SYS:
- Set Debug to Serial Wire
- Set Timebase Source to anything other than SysTick.
- Generate the code. Build and flash.
I discovered the problem after pressing pause during debugging and it shows me that the code is stuck at HAL_NVIC_EnableIRQ() called by HAL_InitTick() which is called by HAL_Init().
Note that this problem only happens when the Timebase Source is modified. Another problem arises when Timebase Source is set to SysTick: HAL_Delay() stalls the code forever since HAL_GetTick() always return 0.
I think I must have missed something trivial in my setup. What am I missing?
I don't think the problem is related to my hardware since I designed my custom board following the reference design provided in the application note. I also refer to other open-source designs that are based on STM32G4 MCUs.
It's worth noting that my board doesn't have external oscillators. Is this related?
