STC15W408AS library 0.9.0
Macros
Power management

Macros

#define WIRC_H_ADDRESS   0xf8
 Wakeup timer internal clock frequency value high byte address.
 
#define WIRC_L_ADDRESS   0xf9
 Wakeup timer internal clock frequency value low byte address.
 
#define idle()   (bit_set(PCON, SBIT0))
 Set MCU idle mode. More...
 
#define power_down()
 Set MCU power down mode. More...
 
#define wakeup_timer_init(ticks)
 Init and run wakeup timer. More...
 
#define wakeup_timer_internal_clk_freq()   (((uint16_t)*wirc_h_ptr << 8) | *wirc_l_ptr)
 Get wakeup timer internal clock frequency. More...
 

Detailed Description

Functions and data structures related for MCU power management

Author
Michael Golovanov

Macro Definition Documentation

◆ idle

#define idle ( )    (bit_set(PCON, SBIT0))

Set MCU idle mode.

Shuts off clock to CPU, but clock to Timers, Interrupts, Serial Ports, and Analog Peripherals are still active. The CPU status is preserved in its entirety: the RAM, Stack Pointer, Program Counter, Program Status Word, Accumulator, and all other registers maintain their data during Idle. The port pins hold the logical states they had at the time Idle was activated.

◆ power_down

#define power_down ( )
Value:
{ \
bit_set(PCON, SBIT1); \
__asm__("nop"); \
__asm__("nop"); \
__asm__("nop"); \
}

Set MCU power down mode.

In the Stop/Power-Down mode, the on-chip oscillator and the Flash memory are stopped in order to minimize power consumption. Only the power-on circuitry will continue to draw power during Stop/Power-Down. The contents of on-chip RAM and SFRs are maintained.

◆ wakeup_timer_init

#define wakeup_timer_init (   ticks)
Value:
{ \
WKTCH = (ticks >> 8) | 0x80; \
WKTCL = ticks & 0xff; \
}

Init and run wakeup timer.

Wakeup time is calculated as (10^6/wakeup_timer_internal_clock_frequency) * 16 * ticks

See also
wakeup_timer_internal_clk_freq()
Parameters
ticksuint16_t wakeup timer ticks count

◆ wakeup_timer_internal_clk_freq

#define wakeup_timer_internal_clk_freq ( )    (((uint16_t)*wirc_h_ptr << 8) | *wirc_l_ptr)

Get wakeup timer internal clock frequency.

wakeup timer internal clock frequency after MCU powerup is placed in RAM __idata 0xf8-0xf9 adresses.

By default SDCC compiler generate firmware part that before main() call clear RAM and 0xf8-0xf9 contains 0x00 values.

To avoid memory clearing implement empty
void _mcs51_genRAMCLEAR() {} routine. Otherwise routine call return result 0x00.

Default value is 0x8c0a = 35850Hz.

Returns
uint16_t wakeup timer internal clock frequency from 0xf8-0xf9 RAM