2024-03-28 02:42 AM
I am using a stm32F103ZET6 to just blinking a led but the HAL_Delay() is not working.
I change the HAL_Delay() with for loop and it work.
this is the code that i am using :
while (1)
{
HAL_GPIO_WritePin(Led_301_GPIO_Port, Led_301_Pin, 1);
HAL_Delay(500);
//for (int i=0; i < 500000; i++);
HAL_GPIO_WritePin(Led_301_GPIO_Port, Led_301_Pin, 0);
//for (int i=0; i < 500000; i++);
}
}
I want to work with HAL_Delay because i need to use it in a project with this mcu
2024-03-28 03:08 AM
Hello,
Did you configure the GPIO pin? The GPIO clock?
Could you share your project?
2024-03-28 03:15 AM
Need two delays otherwise it loops immediately and turns on/off too quickly to see
2024-03-28 04:40 AM
2024-03-28 05:04 AM
In your attached project: you're toggling correctly the pin PA8:
HAL_GPIO_WritePin(Led_301_GPIO_Port, Led_301_Pin, 1);
HAL_Delay(500);
//for (int i=0; i < 500000; i++);
HAL_GPIO_WritePin(Led_301_GPIO_Port, Led_301_Pin, 0);
//for (int i=0; i < 500000; i++);
HAL_Delay(500);
I don't see any issue in your project.
What do you mean by "HAL_Delay() is not working"? what is the symptom?
2024-03-28 05:06 AM
Set a breakpoint in HAL_IncTick() in SysTick_Handler() interrupt handler:
void SysTick_Handler(void)
{
/* USER CODE BEGIN SysTick_IRQn 0 */
/* USER CODE END SysTick_IRQn 0 */
HAL_IncTick();
/* USER CODE BEGIN SysTick_IRQn 1 */
/* USER CODE END SysTick_IRQn 1 */
}
Are you reaching it?
2024-03-28 05:31 AM - edited 2024-03-28 05:44 AM
The symptom is that when I set the LED in the first line, it remains "on". I don't see the LED blinking; it just stays "on". If I reset the LED in the first line, it stays "off". This suggests that the code is likely blocking on line 2 at HAL_Delay(500).
2024-03-28 05:33 AM
I can't debug because I haven't any debug solution
2024-03-28 05:36 AM - edited 2024-03-28 05:39 AM
the stm32F103ZET6 MCU is integrated on a board so i haven't any debug solution.
2024-03-28 05:51 AM
Sorry, which board are you using? how did you upload the binary to board if you don't have a debug solution?