AVR Fuse Bytes:
Atmel Video — Power-Saving Techniques:
Nuts & Volts Forum:
Alternatively, you can use the macro that’s included in
the “sleep.h” library to handle this complexity for you:
Power Reduction Register
Figure 7: Measuring current draw in Project 2.
have a second project!
Squeezing the Last Drops
The PRR allows you to disable the TWI (I2C)
module, Timers 0, 1, and 2, the SPI module, the
USART0, and finally the ADC. Each of these are
disabled by writing a 1 to the corresponding bit in the
register, and enabled by writing a 0. The serial modules
We’ve covered the MCU modules that are disabled
during sleep mode, but what about modules you don’t
need while the microcontroller is running? Additionally,
what if the sleep mode you’re using still has modules in an
The PRR doesn’t only affect sleep modes. It’s a good
way to keep consumption down when the microcontroller
is awake, as well. Now that we’ve touched on these in
theory, let’s put them into practice!
“awake” state when you don’t actually need them? All
sleep modes can be woken by an I2C (TWI) address
match, for example, which means a part of the TWI
module is running even when asleep. If you don’t use TWI
at all, then surely it makes sense to disable it at the outset.
The Second Project:
Going to this level is really squeezing the last drops of
efficiency from your project, but over a period of time it
all adds up. There are two registers that enable us to
disable unused modules: the MCU Control Register
(MCUCR) and the Power Reduction Register (PRR); refer
back to Figure 4.
This simple project uses a pin change interrupt to
toggle an LED. When you press the momentary
pushbutton connected to PB1, the LED on PB0 lights up.
You’re probably thinking that sounds pretty boring; after
all, we’re now eight articles into the series. Well, this is
more of an experiment than a useful project. The idea is
that you’ll measure the impact of the various power-saving
techniques we’ve discussed so far. Hopefully, things are
starting to sound a little more interesting!
MCU Control Register
The MCU Control Register — for our power-saving
purposes — gives us the ability to enable or disable the
BOD while the microcontroller is asleep. The BOD
continuously monitors the voltage supply to the MCU, but
if that’s not needed during sleep, then it makes complete
sense to turn it off. The BODS and BODSE bits are used
to control this, in a somewhat convoluted manner. To
1. Set both BOD and BODSE to “1.”
2. Set BOD to “1” and BODSE to “0” (the latter
within four clock cycles).
3. Enter sleep mode within three clock cycles; in other
words, almost immediately!
First, connect the LED to PB0 (through a resistor as
usual) and a pushbutton to PB1 (connect the button’s
terminal to GND, as we’re using the ATmega’s internal
pull-up resistor). Then, connect a digital multimeter to the
project, so that it is in line with the VCC power supply
(i.e., the power needs to “flow through” the DMM).
Switch the DMM to measure amps and adjust the scale as
you need. We’re ready to start our experiments now.
After each of the below, record the readings on the
DMM (Figure 7). The experiments are clearly commented
in the code, so you should find them easily enough.
Experiment 0: Obtain a baseline reading. We haven’t
implemented any power savings yet, so take a baseline
reading to see just how effective the savings are.
Experiment 1: Uncomment the line of code that sets
60 January 2016