cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_Delay(X) function delays by X/2 (@STM32L0)

Bahadir(Canceled)
Associate III

Hello everyone,

I write HAL_Delay(1000) or HAL_Delay(5000) on my code but it delays it by half. I checked SystickTimer it works fine. But HAL_Delay function gives me half delay time.

I created another project with same board, same Cubemx features , it works fine.

Where should i check at my code to find what's wrong with it (at debug mode)?

1 ACCEPTED SOLUTION

Accepted Solutions
Bahadir(Canceled)
Associate III

Why i did that i don't know but I had written twice HAL_IncTick(); function in the SysTick_Handler.

My stupidity I'm sorry.

It's solved.

Thank you all.

View solution in original post

5 REPLIES 5

What are you using for a clock source, and on what board?

For external clocks watch the define for HSE_VALUE, and use of HSE BYPASS for TCXO/XO type clock sources vs crystals

Internal clocks can typically be exported via MCO/PA8 pin so you can scope them.

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

I am using HSI16, at PLL x4 and /2 32MHz all of the peripherals. Also I have a HSE osc. But situation is same. HAL_Delay gives me delay by half.

MCO is used as a input right now but i'll try tomorrow.

TDK
Guru

HAL_Delay uses SysTick to increment the counter. Can't see how one would be correct and the other would be wrong. The logic is very simple.

Most likely the clock is twice as fast as you think it is.

If you feel a post has answered your question, please click "Accept as Solution".
Bahadir(Canceled)
Associate III

Why i did that i don't know but I had written twice HAL_IncTick(); function in the SysTick_Handler.

My stupidity I'm sorry.

It's solved.

Thank you all.

Thanks for the update on that. That would certainly do it..

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