Page 1 of 1

Deep sleep

PostPosted: Tue Dec 20, 2005 9:07 am
by rbsjrx
In reading your documentation and playing with your code, I can't see how easily I can write an application that spends every possible moment hibernating. We require extremely low average power consumption, yet we have some computationally intensive tasks to perform. We're using the TI MSP430 and intend to put it into a deep sleep whenever there are no numbers to crunch. It should stay asleep until either a timer or communications interrupt. From your product description, it sounds like you need the CPU active most of the time to service the timers.

Re: Deep sleep

PostPosted: Wed Dec 21, 2005 10:02 am
by aek
You definitely don't need the CPU active ... the system will be sleeping whenever there are no eligible tasks. Tasks can be waiting or delayed and the system can sleep (i.e. the CPU can be off).

The sequence will be as follows:

  • an internal or external event (like a timer ISR occurring -- that's an internal event) will wake the system
  • the CPU will power up
  • you'll process the interrupt (which, in this case includes a call to Salvo's OSTimer())
  • you'll exit the ISR with no LPM mode active
  • the code will resume mainline execution (right after where it went to sleep in the idling hook)
  • you'll exit OSSched() (the idling hook was vectored to from within the scheduler)
  • you'll re-enter OSSched() in main() and OSSched() will figure out if any task(s) is(are) now eligible. In this example, if a task had been delayed and its delay timed out on this tick (i.e. this interrupt), then that task would be made eligible again
  • the formerly delayed task now runs
  • once no more tasks are eligible (this would happen very quickly in this example if the delayed task delays itself again), then the idling hook is called again, and the system goes back to sleep
The key point here is that not a single CPU cycle need be expended while waiting for events to happen. If you leave the idling hook blank, then the system will simply call OSSched() repeatedly from within main(), and OSSched() will have nothing to do, other than run the idling hook. But you can put the system to sleep from within the idling hook, which is recommended.

On the MSP430, you can probably set things up for LPM3, so that only the ACLK is active, and that is the clock that is used to drive the timer that runs at the system tick rate and calls OSTimer().


[This message has been edited by aek (edited December 21, 2005).]