HAL_Delay(X) function delays by X/2 (@STM32L0)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-08 6:31 AM
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)?
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-09 12:48 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-08 6:46 AM
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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-08 6:55 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-08 7:14 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-09 12:48 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-13 10:57 AM
Thanks for the update on that. That would certainly do it..
Up vote any posts that you find helpful, it shows what's working..
