Jump to content

Delay() and sleep() have different timing cycles.

Recommended Posts


I am using MSP430 launchpad with G2553 controller. When I am using sleep(5000), and varying the voltage on the controller from 3v to 4v the timing is varying based on the voltage, but the timing in not changing when I am using delay(5000) when I am varying voltage. Any help will be appreciated. 


Link to post
Share on other sites

The delay() function is part of the official Arduino API. It is implemented with a busy loop, based on the CPU clock.

The sleep() function is not part of the official Arduino API. It powers down the CPU, and measures time based on the VLO, which doesn't have a accurately specified frequency to begin with and has much higher temperature and voltage coefficients than other clock sources.

Link to post
Share on other sites

Please also see the comment here I posted here on github here: https://github.com/energia/Energia/issues/569#issuecomment-316120507

Copy of that post:

"VLO has a typical frequency of 12kHz hence this is the value used in the code for vlo_freq. With that said, VLO, as per datasheet, has a minimal value of 4kHz and a maximum value of 20kHz. The frequency it settles on varies by part, temperature, power supply, etc. Hence it can end up anywhere between 4 kHz and 20 kHz. Unfortunately there is no way to measure the VLO Freq. on startup. If you would like accurate sleep times then I suggest that you install the 32kHz watch crystal that came with the LaunchPad in the box.
Also see this thread for additional information about the sleep() and sleepSeconds() implementation: http://forum.43oh.com/topic/4571-building-low-power-into-energia/?page=2#comment-46495

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...