Documentation  |   Table of Contents   |  < Previous   |  Next >   |  Index

9    Power Management

System Management

Exploring Palm OS®

Palm OS® differs from a traditional desktop system in that it's never really turned off. Power is constantly supplied to essential subsystems, and the power button is merely a way of bringing the device in or out of low-power mode. The obvious effect of pressing the power button is that the LCD turns on or off. When the user presses the power key to turn the device off, the LCD is disabled, which makes it appear as if power to the entire unit is turned off. In fact, the memory system, real-time clock, and the interrupt generation circuitry are still running, though they are consuming little current.

This chapter looks at Palm OS power management, discussing the following topics:

Palm OS Power Modes ^TOP^

To minimize power consumption, the operating system dynamically switches between three different modes of operation: sleep mode, doze mode, and running mode. The System Manager controls transitions between different power modes and provides an API for controlling some aspects of the power management.

  • In sleep mode, the device looks like it's turned off: the display is blank, the digitizer is inactive, and the main clock is stopped. The only circuits still active are the real-time clock and interrupt generation circuitry.

    The device enters this mode when there is no user activity for a number of minutes or when the user presses the power button. The device comes out of sleep mode only when there is an interrupt, for example, when the user presses a button.

    To enter sleep mode, the system puts as many peripherals as possible into low-power mode and sets up the hardware so that an interrupt from any hard key or the real-time clock wakes up the system. When the system gets one of these interrupts while in sleep mode, it quickly checks that the battery is strong enough to complete the wake-up and then takes each of the peripherals, for example, the LCD, serial port, and timers, out of low-power mode.

  • In doze mode, the main clock is running, the device appears to be turned on, the LCD is on, and the processor's clock is running but it's not executing instructions (that is, it's halted). When the processor receives an interrupt, it comes out of halt and starts processing the interrupt.

    The device enters this mode whenever it's on but has no user input to process.

    The system can come out of doze mode much faster than it can come out of sleep mode since none of the peripherals need to be woken up. In fact, it takes no longer to come out of doze mode than to process an interrupt. Usually, when the system appears on, it is actually in doze mode and goes into running mode only for short periods of time to process an interrupt or respond to user input like a pen tap or key press.

  • In running mode, the processor is actually executing instructions.

    The device enters this mode when it detects user input (like a tap on the screen) while in doze mode or when it detects an interrupt while in doze or sleep mode. The device stays in running mode only as long as it takes to process the user input (most likely less than a second), then it immediately reenters doze mode. A typical application puts the system into running mode only about 5% of the time.

To maximize battery life, the processor on the Palm Powered™ device is kept out of running mode as much as possible. Any interrupt generated on the device must therefore be capable of "waking" the processor. The processor can receive interrupts from the serial port, the hard buttons on the case, the button on the cradle, the programmable timer, the memory module slot, the real-time clock (for alarms), the low-battery detector, and any built-in peripherals such as a pager or modem.

Guidelines for Application Developers ^TOP^

Normally, applications don't need to be aware of power management except for a few simple guidelines. When an application calls EvtGetEvent() to ask the system for the next event to process, the system automatically puts itself into doze mode until there is an event to process. As long as an application uses EvtGetEvent(), power management occurs automatically. If there has been no user input for the amount of time determined by the current setting of the auto-off preference, the system automatically enters sleep mode without intervention from the application.

Applications should avoid providing their own delay loops. Instead, they should use SysTaskDelay(), which puts the system into doze mode during the delay to conserve as much power as possible. If an application needs to perform periodic work, it can pass a timeout to EvtGetEvent(); this forces the unit to wake up out of doze mode and to return to the application when the timeout expires, even if there is no event to process. Using these mechanisms provides the longest possible battery life.

Power Management Calls ^TOP^

The system calls SysSleep() to put itself immediately into low-power sleep mode. Normally, the system puts itself to sleep when there has been no user activity for the minimum auto-off time or when the user presses the power key.

The SysSetAutoOffTime() routine changes the auto-off time value. This function is normally only used by the Preferences application and by the system during boot. The Preferences application saves the user preference for the auto-off time in a preferences database, and the system initializes the auto-off time to the value saved in the preferences database during boot. While the auto-off feature can be disabled entirely by calling SysSetAutoOffTime() with a timeout value of 0, doing this depletes the battery.

The current battery level and other information can be obtained through the SysBatteryInfo() routine. This function returns information about the battery, including the current battery voltage in hundredths of a volt, the warning thresholds for the low-battery alerts, the battery type, and whether external power is applied to the unit. This call can also change the battery warning thresholds and battery type.