Microcontrollers are integrated circuits that contain a processor core, memory, and programmable input/output peripherals. They are used in a wide variety of embedded systems and Internet of Things (IoT) devices. One important consideration when designing products with microcontrollers is power consumption, especially for battery-powered devices.
Microcontrollers have various low power modes that allow the device to reduce its power consumption when not needing to run at full processing capacity. Using low power modes appropriately can extend battery life and reduce heat generation. The main ways microcontrollers enter low power modes are by reducing clock speed, disabling peripherals, and putting the processor into sleep or deep sleep modes.
Reduced Clock Speed
Most microcontrollers have the ability to run the processor core at different clock speeds. The higher the clock speed, the faster the processor can execute instructions. However, higher clock speeds also mean greater power consumption. When the microcontroller does not need full processing power, the clock can be reduced to lower power usage.
For example, the processor may run at 72MHz when active but scale down to 24MHz or even 2MHz when only monitoring sensors or waiting for external input. Slowing the clock speed proportionally reduces the power draw of the processor core. The microcontroller may have built-in hardware to manage clock speed, or the firmware can configure clock settings dynamically.
Disabling Peripherals
Microcontrollers include integrated peripherals like serial ports, timers, ADC converters, I2C/SPI interfaces, and more. When these peripherals are not in use, they can often be disabled to reduce power. The firmware will configure enable/disable settings for each peripheral as needed.
For example, if the system only uses the ADC converter to measure a sensor every few seconds, the ADC can be disabled in between readings. Or if the serial port is only used occasionally for debug output, it can remain disabled most of the time. Turning off unused peripherals prevents unnecessary power draw from those modules.
Sleep and Deep Sleep Modes
In addition to peripheral management and clock scaling, microcontrollers also support sleep and deep sleep low power modes. These modes essentially turn off the CPU core and memory while retaining state information. The processor halts execution and waits for an interrupt or reset to wake up.
Sleep mode turns off the CPU and optionally disables peripherals and memory. Dynamic RAM contents may be lost in sleep mode. Wakeup latency is very fast, allowing quick response to interrupts. Deep sleep mode turns off more circuitry, including flash memory and register contents. Latency is higher as registers need to be restored on wakeup, but power savings are greater.
Implementing Sleep and Deep Sleep
The firmware initiates sleep or deep sleep modes by configuring settings in the microcontroller’s power management unit (PMU). This includes selecting which peripherals to disable and what wake events to detect. Common wake events are external interrupts on GPIO pins, ADC results, timer timeouts, and communication interface activity.
The microcontroller may also have low-power modes specifically for peripheral operation that allow the CPU to sleep while peripherals remain active. As an example, the ADC converter could collect sensor measurements while the CPU sleeps, waking only to process results.
Design Considerations
When using sleep and deep sleep modes, the firmware developer must consider several factors:
- What state needs to be retained? CPU, peripherals, memory contents?
- What can trigger wakeup? Interrupts, resets, debug access?
- What events need to wakeup the system? Time for next task, external stimulus detected, data received?
- How to minimize wakeup latency for critical tasks?
- Are interrupts synchronized across multiple peripherals?
Careful use of low power modes allows tradeoffs between power savings, wakeup latency, and system responsiveness. The firmware should be designed to maximize sleep time while still meeting operational requirements.
Summary
The main techniques microcontrollers use to reduce power consumption are:
- Scale CPU clock speed based on required performance.
- Disable unused peripherals.
- Use sleep or deep sleep modes to halt CPU and memory.
- Design firmware to sleep as much as possible while still meeting system needs.
- Configure appropriate wake events from sleep/deep sleep modes.
Optimizing low power modes requires balancing power savings, latency, and system responsiveness. But when done effectively, low power design can greatly extend battery life and reduce heat generation in microcontroller-based systems.