cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_delay not working?

retro
Associate III

SOS

I have tried the other forum suggestions but nothing seems to work so far for me. Basically I am just trying to turn an LED on/off with a set delay:

 while (1)

 {

   /* USER CODE END WHILE */

    HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, 0);

    HAL_Delay(1000);

    HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, 1);

    /* USER CODE BEGIN 3 */

 }

It just hangs at HAL_Delay(1000). I am using a STM32L496G-DISCO board.

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

What happens if you step into HAL_Delay ?

What does 'hanging' exactly mean?

Btw: You need another delay to see the LED blinking, because its now 1000ms on + 0ms off.

View solution in original post

7 REPLIES 7
Vivek yadav1
Associate III

Hi @retro​ 

Check your RCC clock config.

is that in the .ioc - clock configuration? I cannot see anything about RCC

KnarfB
Principal III

What happens if you step into HAL_Delay ?

What does 'hanging' exactly mean?

Btw: You need another delay to see the LED blinking, because its now 1000ms on + 0ms off.

@retro​ 

Are you using CubeMx for auto code generation ?

Which board are you using ?

Did you config GPIO port Pin as output ?

/*********************************

I Set GPIOC pin 0 as output.

while(1)

{

  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_RESET);

    HAL_Delay(1000);

   HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_SET);

 HAL_Delay(1000);

}

/*********************************

Still facing issue let me know.

Yes this was the problem - I am actually smart I swear

retro
Associate III

Yes, I did not put another delay after that - do not judge me - it works now!

Well that is great.

I am not judging you. I am surprised that why did you think so.