2023-05-15 06:08 AM
2023-05-15 06: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
2023-05-15 06:25 AM
Thanks, is that possible if i use interrupt instead of delay in my case?
2023-05-15 06: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