Skip to main content

Microcontrollers

Chapter 11 Power Management and Sleep Modes

Power defines the rate at which electrical energy is used in a circuit. The power consumed by a microcontroller circuit affects either the battery life of the batteries used to power it, or the cost of the electricity used to power it from a wall outlet. Reducing the power consumed by a microcontroller circuit can therefore lower costs. If an embedded system is built with a battery that cannot be recharged or replaced, reducing power consumption will increase the lifespan of the device.
Electrical power in a direct current circuit is defined by (11.0.1), where \(P\) is the power consumed in mW, \(V\) is the voltage in V, and \(I\) is the current in mA. If voltage is fixed (typically it is constant and equal to VCC in a digital circuit), then reducing current will reduce power consumption.
\begin{equation} P = IV\tag{11.0.1} \end{equation}
The ATmega328P has multiple methods to affect the power consumption, including (but not necessarily limited to)
The ATmega328P power reduction register (PRR) can be used to disable unused peripherals by turning off the associated clock signal. When a peripheral is disabled in PRR, its corresponding registers are frozen and are unable to be read from or written to.
I/O pins connected to devices such as pushbuttons, switches, motors, LEDs, segmented displays, and LCD screens will either source or sink current. Many times this is unavoidable. However, the amount of current sourced or sunk by each I/O pin can be reduced by carefully selecting resistor values. Ohm’s law, defined in (11.0.2) (where \(I\) is current in mA, \(V\) is voltage in V, and \(R\) is resistance in kΩ), states that if voltage is constant, current is reduced when resistance is increased.
\begin{equation} I = \frac{V}{R}\tag{11.0.2} \end{equation}
Increasing the resistance connected to an I/O pin is not always feasible. In some cases (such as with motors), the resistance of a device is fixed. When using an input device such as a pushbutton or switch, the value of pull-down or pull-up resistor cannot be too high, otherwise it will lead to floating inputs. When using an output device such as an LED or LCD screen, current-limiting resistors that are too large can cause the output to become dim to the point where it is unreadable.
The ATmega328P datasheet ([16.14]) recommends ensuring that any disconnected I/O pins have a defined voltage level. The simplest way to define a voltage level on unused input pins is to activate the internal pull-up resistor.
The brown-out detection (BOD) unit consumes power and should be disabled either in the extended fuse byte (introduced in SubsectionΒ 4.7.1) or by configuring the associated bits in the MCU control register (MCUCR) if brown-out detection is not needed.
Power consumption is affected by the frequency of operation of a microcontroller. The faster the clock frequency, the more power will be consumed (all other things being equal). Power consumption can therefore be reduced by lowering the clock frequency (either by using an external clock or by using a global clock prescaler as described in SectionΒ 9.1). This may not always be possible in situations where the microcontroller requires a particular output response.