Hi dear friends,
How can i have an exact delay ? for example when i writhe HAL_Delay(1); i don't have exactly 1ms but 1,6ms for example. For example in my case between 2 PWM functions, Start and Stop, do you have any idea about that?
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-15 6:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-15 6:15 AM
> for example when i writhe HAL_Delay(1); i don't have exactly 1ms but 1,6ms for example.
HAL_Delay(x) is a delay which lasts *at least* x ms, but may last more.
> How can i have an exact delay ?
Write your own, e.g. based on timers.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-15 6:25 AM
Thanks, is that possible if i use interrupt instead of delay in my case?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-15 6:35 AM
I don't know, this depends on your application.
If you mean a timer interrupt, i.e. set up a timer so that it will interrupt every 1ms and then perform the task you intended in that interrupt, then yes, the tasks will be executed 1ms apart - unless there is an interrupt with higher priority which takes too long.
JW
