cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_Delay() not working on STM32F103ZET6 (LED Blinking Example)

Helmish
Associate II

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

 

15 REPLIES 15
SofLit
ST Employee

Hello,

Did you configure the GPIO pin? The GPIO clock?

Could you share your project?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Need two delays otherwise it loops immediately and turns on/off too quickly to see

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

this is the project.

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?

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
SofLit
ST Employee

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?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

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).

I can't debug because I haven't any debug solution

the stm32F103ZET6 MCU is integrated on a board so i haven't any debug solution.

Sorry, which board are you using? how did you upload the binary to board if you don't have a debug solution?

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.