cancel
Showing results for 
Search instead for 
Did you mean: 

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

HA.5
Associate III
 
3 REPLIES 3

> 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

HA.5
Associate III

Thanks, is that possible if i use interrupt instead of delay in my case?

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