HAL_Delay() does not work...
- September 16, 2021
- 2 replies
- 4600 views
Hi, I know there are other posts on this forum about this issue, but have not been able to solve my problem even when implementing the fixes those posts suggest. I am a total newbie to STMCubeMX etc - this is my first project on any ST MCU. Here are some details about my situation:
MCU: STM32F405RGT6
Programmer: ST-LINK V2 (blue USB) - GDB server
I try running HAL_Delay(500) and I step into the function using the debugging mode. My understanding is that this function relies on a periodic interrupt of the CPU (every 1 ms), at which point the HAL_IncTick() function is called, eventually increasing the number of ticks until the delay is complete. I took a look at the NVIC configuration as others suggested in posts - I set all the interrupts that I had control over to 1 (lower priority than the systick interrupt, which I left at priority 0). Still didn't stop the problem.
I also found that for some reason (can anyone elaborate as to why?), the NMI interrupt handler and the HardFault interrupt handler both have while(1){} loops inside them. Given that these two interrupts take 0 priority (which I can't seem to change from CubeMX), I wonder if one of these interrupts are being triggered and then the whole processor is stuck in this while(1) loop? I added break statements within the while(1) loops - didn't help.
It seems like the code just gets stuck in the HAL_GetTick() function in stm32f4xx_hal.c (image attached).
At this point, I'm out of ideas. Does anyone have some suggestions on what else to try? As I'm a newbie, I don't know the ins and outs of HAL and don't have the skills to troubleshoot any deep-rooted problem.
