Power modes especially become more important where power saving is needed. All common microcontrollers have several power control modes.LPC21xx series microcontrollers have to reduced power modes: idle and power-down mode.
Idle mode
Execution of instructions is suspended until reset or another interrupt signal occurs. In idle mode, peripheral devices (for instance, timer) are running and may generate interrupts that cause the processor to resume execution. So idle mode eliminates power used by the processor itself, memory system, and internal buses.
Power-down mode
When the power-down mode is selected, the oscillator is stopped, so the chip doesn’t receive internal clocks. After this mode is selected, all current register and memory values are preserved, all logic levels of the chip remain static. The processor may be resumed by reset signal or by another external interrupt, which doesn’t require internal clocking (in our case, it would be an external interrupt). Power down mode reduces chip power consumption to nearly zero.
Entering to power down mode or idle mode is done via software while resuming is done automatically by an interrupt. Resuming is performed in such a way that no instructions or any data are lost.
It is also possible to turn Off peripherals individually if they are not needed to save additional power.
Power control registers
Power control of ARM LPC2000 series MCU is done via two control registers: PCON and PCONP.
- PCON – Power Control Register. This register contains control bits that enable the two reduced-power operating modes (idle and power-down) of the microcontroller;
- PCONP – Power Control for Peripherals Register. The register contains control bits that enable and disable individual peripheral functions.
Bit 0 of the PCON register turns on idle mode (bit IDL=“1”). Setting this bit processor block stops but peripherals remain active. Any enabled interrupt resume processor block action.
Bit 1 of the PCON register turns on power-down mode (bit PD=“1”). All on-chip blocks are stopped. Only external interrupt or reset may wake the processor and resume operations.
Other bits of the PCON register is used to control Brown Out Detection (BOD) – refer to the datasheet.
As we mentioned, there is possible to control distinct peripheral devices. This is done by setting PCONP register values. This register is simply gating off peripheral blocks. Some peripherals like WD timer, GPIO System control block cannot be turned off. Some peripherals may be turned off, particularly those who include analog functions and may consume that si, not clock dependant. Each bit of PCONP controls one of the peripherals. If the bit is “1”, then peripheral is enabled; if “0” then it is disabled to conserve the power.
Example for LPC2148 microcontroller
Power Control for Peripherals register (PCONP – address 0xE01F C0C4)
- 0 – Reserved, user software should not write ones to reserved bits;
- 1 PCTIM0 Timer/Counter 0;
- 2 PCTIM1 Timer/Counter 1;
- 3 PCUART0 UART0;
- 4 PCUART1 UART1;
- 5 PCPWM0 PWM0;
- 6 – Reserved;
- 7 PCI2C0 The I C0 interface;
- 8 PCSPI0 The SPI0 interface;
- 9 PCRTC The RTC;
- 10 PCSPI1 The SSP interface;
- 11 – Reserved;
- 12 PCAD0 A/D converter 0 (ADC0); Note: Clear the PDN bit in the AD0CR before clearing this bit, and set this bit before setting PDN;
- 18:13 – Reserved;
- 19 PCI2C1 The I2C1 interface;
- 20 PCAD1 A/D converter 1 (ADC1). Note: Clear the PDN bit in the AD1CR before clearing this bit, and set this bit before setting PDN;
- 30:21 – Reserved;
- 31 PUSB USB.
After RESET, all peripherals are enabled. This is a good practice during the initialization of MCU to disable all unused peripherals.
Some unofficial tests show that LPC2000 running at 60MHz consumes about 30 – 40mA of current while in the power-down mode, it only 10- 15μA. Also, remember that debugging isn’t possible during the idle or power-down mode.