tk_set_pow

Set Power Mode

[C Language Interface]

ER ercd = tk_set_pow ( UINT powmode ) ;

[Parameters]

UINT powmod Low-power mode

[Return Parameters]

ER ercd Error code

[Error Codes]

E_OK Normal completion

E_PAR Parameter error (value that cannot be used in powmode)

E_QOVR Low-power mode disable count overflow

E_OBJ TPW_ENALOWPOW was requested with low-power mode disable count at 0

[Description]

The following two power-saving functions are supported.

  • Switching to low-power mode when the system is idle

When there are no tasks to be executed, the system switches to a low-power mode provided in hardware. Low-power mode is a function for reducing power use during very short intervals, such as from one timer interrupt to the next. This is accomplished, for example, by lowering the CPU clock frequency. It does not require complicated mode-switching in software but is implemented mainly using hardware functionality.

  • Automatic power-off

When the operator performs no operations for a certain length of time, the system automatically cuts the power and goes to suspended state. If there is a start request (interrupt, etc.) from a peripheral device or if the operator turns on the power, the system resumes from the state when the power was cut. In the case of a power supply problem such as low battery, the system likewise cuts the power and goes to suspended state.

In suspended state, the power is cut to peripheral devices and circuits as well as to the CPU, but the main memory contents are retained.

tk_set_pow sets the low-power mode.

powmode:= ( TPW_DOSUSPEND || TPW_DISLOWPOW || TPW_ENALOWPOW )

TPW_DOSUSPEND Suspended state

TPW_DISLOWPOW Switching to low-power mode disabled

TPW_ENALOWPOW Switching to low-power mode enabled (default)


#define	TPW_DOSUSPEND	1	Suspended state
#define	TPW_DISLOWPOW	2	Switching to low-power mode disabled
#define	TPW_ENALOWPOW	3	Switching to low-power mode enabled (default)
  • TPW_DOSUSPEND

Execution of all tasks and handlers is stopped, peripheral circuits (timers, interrupt controllers, etc.) are stopped, and the power is cut (suspended). (off_pow is called.)

When power is turned back on, peripheral circuits are restarted, execution of all tasks and handlers is resumed, operations resume from the point before power was cut, and the system call returns.

If for some reason the resume processing fails, normal startup processing (for reset) is performed and the system boots fresh.

  • TPW_DISLOWPOW

Switching to low-power mode in the dispatcher is disabled. (low_pow is not called.)

  • TPW_ENALOWPOW

Switching to low-power mode in the dispatcher is enabled. (low_pow is called). The default at system startup is low-power mode enabled (TPW_ENALOWPOW).

Each time TPW_DISLOWPOW is specified, the request count is taken. Low-power mode is enabled only when TPW_ENALOWPOW is requested for as many times as TPW_DISLOWPOW was requested. The maximum request count is implementation-dependent, but a count of at least 255 times must be possible.

[Additional Notes]

off_pow and low_pow are T-Kernel/SM functions. See 5.6 for details.

T-Kernel does not detect power supply problems or other factors for suspending the system. Actual suspension requires suspend processing in each of the peripheral devices (device drivers). The system is suspended not by calling tk_set_pow directly but by use of the T-Kernel/SM suspend function.

Comments