2026-02-12 11:20 AM
Im trying to use the HAL_Delay function but it seems like to code does not get passed this function. I have no clue what to even check to figure out what the problem is. I have attached the main fail to this post.
2026-02-12 11:26 AM
I can't even see the HAL_Delay() you call ...
2026-02-12 11:27 AM
Hello,
No call to HAL_Delay() in the files you shared.
Could you please double check?
Also you need to tell at which line/file in your code HAL_Delay() is not working as expected.
2026-02-12 12:16 PM - last edited on 2026-02-12 12:28 PM by mƎALLEm
Murged threads for the same question.
Im try to use HAL_Delay() to delay my code but it kept getting stuck in HAL_Delay(). I stepped through the code and realized that HAL_GetTickI() kept returning 0. I am using an STM32CubeIDE to program an nucleo F411RE.
The HAL_Delay() is on line 123 in main.c.
HAL_GetTick() is defined on line 323 in stm32f4xx_hal.c.
HAL_Delay() is defined on line 390 in stm32f4xx_hal.c.
2026-02-12 12:20 PM
As I was posting this I accidentally changed line 323 but it used to be this:
__weak void HAL_Delay(uint32_t Delay)
it won't run without this correction but the issue mentioned above still remains even with this correction.
2026-02-12 12:31 PM
Ok let's proceed step by step.
What if you comment out this code?:
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_TIM1_Init();
MX_TIM2_Init();
MX_TIM4_Init();
/* USER CODE BEGIN 2 */
HAL_TIM_Encoder_Start(&htim1, TIM_CHANNEL_ALL);
HAL_TIM_Encoder_Start(&htim2, TIM_CHANNEL_ALL);
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_1);
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_2);
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_3);
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_4);
Do you reach turn(1);?
2026-02-12 1:18 PM
Maybe in CubeMX "Pinout & Configuration -> SYS -> Timebase Source" is connected to a timer which is not started?