EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

difference between IntervalMs and DelayMs

Started by "yan...@omniverter.com [rabbit-semi]" September 30, 2016
Hello,

I have couple costate loop. When I use wait(DelayMs(500)) after task is finished and make costate to wait, sometimes my controller is frozen, but when I use wait(IntervalMs(500)), it seems controller is working properly.

Does any body know the difference between these two functions?

Thanks a lot.
DelayMs(500) is supposed to wait 500ms.

IntervalMs(500) will wait until 500ms has elapsed since the last time you called it.

The difference is that if you have something you want to do every 500ms, use IntervalMs(500). If you want to wait 500ms after you’ve completed a task before starting it again, use DelayMs(500).

If your task took exactly 100ms, the DelayMs() method would happen every 600ms whereas the IntervalMs() method would happen every 500ms. I imagine IntervalMs() is handy when the task requires some variable amount of time.

I’m not sure why your controller would freeze when using DelayMs() versus IntervalMs(), and would suspect a bug elsewhere in your code.

-Tom

From: r... [mailto:r...]
Sent: Friday, September 30, 2016 12:21 PM
To: r...
Subject: [rabbit-semi] difference between IntervalMs and DelayMs

Hello,

I have couple costate loop. When I use wait(DelayMs(500)) after task is finished and make costate to wait, sometimes my controller is frozen, but when I use wait(IntervalMs(500)), it seems controller is working properly.

Does any body know the difference between these two functions?

Thanks a lot.

_,___

The 2024 Embedded Online Conference