This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/MSP430G2553: Delay() and Sleep() timing requirement.

Part Number: MSP430G2553
Other Parts Discussed in Thread: ENERGIA

Tool/software: TI C/C++ Compiler

Hi,

I am using msp430g2553 microcontoller. When I am using delay() and changing the Vcc from 4v to 2.8v the time remains constant (clock not dependent on the voltage). But when I am using sleep() function the time changes when changing from 4v to 2.8v.

  • Where do these functions come from? Are you talking about Energia?
  • Yes, I am talking about Energia.
  • 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.
  • Sleep() function is not official function but I can see about sleep function in energia and arduino reference pages. What does it mean it is not official function, I am not getting it.? 

    I am not aware of this fact that delay() works on DCO and sleep() works on VLO clock source. I have a question if in my code I have configured DCO to 1MHz and then later uses sleep() function,  will the microcontroller automatically switches from DCO clock source to VLO.  This is what I have done and the clock timing are very much dependent on voltage given to microcontroller.

    Is it possible to use sleep mode while using DCO as clock source. Any help will be appreciated. 

    Regards,

  • You can use sleep() with Energia, but maybe not with other Arduino(-compatible) microcontrollers.

    To change how sleep() behaves, you have to modify the Energia source code.
    • If I remember correctly using the sleep() command in energia switches the MCU to LPM3.  In this mode the VLO clock is used in order to achieve the low power state of LPM3.  I don't believe that you can run the DCO and achieve low power at the same time.  If your time in sleep/LPM is critical perhaps you can use an external interrupt source as a more precise way to exit out of LPM3.
    • EDIT:  Are you using the external 32K crystal?  Not sure if energia supports it but it should give you a more accurate interval at the cost of slightly higher power consumption than the VLO(See datasheet pg. 23).

**Attention** This is a public forum