tapasxplore

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

4 posts in this topic

Hi,

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. 

Regards,

Share this post


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.

tripwire, Fmilburn, energia and 1 other like this

Share this post


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
"

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now