After the basic functions of the system clock generator are established, the scg1, scg0, cpuoff, and oscoff bits of the SR in the CPU are important low-power control bits. As long as any interrupt is responded, the above control bit is pushed into the stack for storage. After the interrupt is processed, the previous working mode can be restored. These control bits can be operated by indirectly accessing stack data during execution of Interrupt Processing subprograms; this allows the program to continue running in another power consumption mode after the interrupt return (RETI.
The role of each control bit is as follows:
Scg1: reset to enable smclk; reset to disable smclk.
Scg0: reset and activate the DC generator. The DC generator can be disabled only when scg0 is set and dcoclk is not used as mclk or smclk.
Oscoff: reset to activate lfxt1. flxt1 can be disabled only when oscoff is set and lfxt1clk is not used for mclk or smclk. When oscoff is disabled using a crystal oscillator, the start time of the crystal oscillator needs to be considered.
Cpuoff: reset, enable mclk; set, disable mclk.
The control bit scg1, scg0, cpuoff, and oscoff can be configured by the software into six different working modes:
The working mode controls the CPU status, oscillator, and clock of the bit.
Scg1 = 0 CPU Activity
Scg0 = 0 mclk Activity
AMCpuoff = 0 smclk Activity
Oscoff = 0 aclk Activity
Scg1 = 0 CPU disabled
Lpm0Scg0 = 0 mclk disabled
Oscoff = 0 smclk Activity
Cpuoff = 1 aclk Activity
Scg1 = 0 CPU disabled
Mclk disabled
Lpm1Scg0 = 1 if the dcoclk bit is used as the mclk or smclk, the DC Generator is disabled,
Otherwise, the activity is still active.
Oscoff = 0 smclk Activity
Cpuoff = 1 aclk Activity
Scg1 = 1 CPU disabled
If DCO is not used as mclk or smclk, it is automatically disabled.
Scg0 = 0 mclk disabled
Lpm2Oscoff = 0 smclk disabled
Cpuoff = 1 aclk Activity
Scg1 = 1 CPU disabled
DCO is disabled, DC Generator is disabled
Scg0 = 1 mclk disabled
Lpm3Oscoff = 0 smclk disabled
Cpuoff = 1 aclk Activity
Scg1 = 1 CPU disabled
Scg0 = 1 DCO disabled, DC Generator disabled
Lpm4Oscoff = 1 All oscillator stops working
Disable mclk and smclk
Cpuoff = 1 aclk disabled
Design tips for Low Power Consumption
1. lpm4: When the oscillator is switched off, all parts of the processor are stopped and the current consumption is minimized. At this time, only when the system power-on circuit detects a low level or any external interrupt event that requests an asynchronous response to the interruption will the system work again. Therefore, this mode should be used only when the design contains external interruptions that may be needed, otherwise unexpected results may occur.
2. lpm3: During DC Shutdown, only the crystal oscillator is active. However, the DC current of the DC generator that sets the basic timing condition is disabled. Due to the high-impedance design of this circuit, power consumption is restrained. It takes some time (NS ~ US)
3. lpm2: during this period, the crystal oscillator and DC Generator work, so it can be quickly started.
4. lpm1: the oscillator has been working during this period, so there is no startup delay problem.
_ Bis_sr (lpm3_bits) _ bic_sr_irq (lpm3_bits)
Lpm3 lpm3_exit
System Response interruption process:
1. Automatic hardware interruption
A. PC inbound Stack
B. Sr inbound Stack
C. Assign the interrupt vector to the PC
D. clear idea about Gie, scg1, cpooff, and oscoff
E. Clear the IFG flag (Single-source disconnection flag, such as wdtifg)
2. Execute the Interrupt Processing subroutine
3. Execute the rETI command
4. Sr output Stack
5. PC output Stack
Low-power applications
Void main (void)
{
Wdtctl = wdt_adly_1000;
Ie1 | = wdtie;
P1dir | = 0x01;
_ Eint ();
For (;;)
{
Lpm3;
_ Nop ();
}
}
Interrupt [wdt_vector] watchdog_timer (void)
{
P1out ^ = 0x01;
}