to get a little more insight into the clocks that
operate inside your ATmega328P. They are what
we use to put the microcontroller to sleep. As you
continue reading, refer to Figure 3 for a summary
of the sleep modes.
This mode results in the least savings because it
only shuts down the CPU and the Flash memory
interface, leaving everything else running. It does
this by disabling the clkCPU (CPU clock) and the
clkFLASH (Flash clock). This means that the MCU can
be woken by pretty much any internal or external
interrupt — including ADC-driven, timer-driven, and
USART-driven interrupts. From this perspective, it is
the most flexible of the six modes.
ADC Noise Reduction Mode
This mode is designed to improve the accuracy of
ADC readings, and is not really a power-saving method.
By shutting down the CPU (clkCPU), the Flash interface
(clkFLASH) and the I/O module (clkIO) on-chip noise is
reduced, resulting in higher resolution ADC
measurements. If your ADC is enabled, entering this sleep
state will automatically start an ADC read operation — and
then the ADC Conversion Complete interrupt will wake
the microcontroller up again. Other interrupts are able to
wake the MCU, but typically wouldn’t be needed.
Extended Standby Mode
Before continuing, I need to comment that I have a
great deal of sympathy for the engineer that was tasked
with naming these various modes. It is impossible to name
them in a way that is at all descriptive of their function.
So, as you read on, wonder at their cryptic naming and be
grateful that neither of us had to choose the names!
Extended Standby mode is a good middle-ground
mode. It is efficient, but retains some of the flexibility that
I find useful. All the clocks except for the Asynchronous
Timer clock (clkASY) are stopped, meaning that if Timer2 is
running, it will continue to run during sleep. This allows
you to use Timer2 to wake the microcontroller up. The
main oscillator also remains running, so the MCU will
wake up quickly — in six clock cycles.
This is more efficient than Extended Standby mode, as
the main oscillator does not run. Otherwise, it is identical
to the Extended Standby mode. The impact of the main
oscillator not running is that the MCU takes longer to
wake up — pretty much the same time as it does after a
Standby mode is the second most efficient mode, and
also the least flexible. All clocks are stopped (clkCPU,
January 2016 57
Figure 4: Summary of sleep
and power registers.
How Many Clocks?
Your microcontroller has five clocks — that’s right, five:
the CPU clock, the Flash clock, the I/O clock, the
Asynchronous Timer clock, and the ADC clock. It took me a
long time to get my head around all of these clocks and how
they worked. If you feel similar, then take heart! You’ve been
working with most of these already! In essence, the
ATmega328P has a Clock Control Unit that takes the clock
source (an oscillator) and distributes it to each of these
Here’s a quick round-up of the clocks:
• CPU Clock (clkCPU): This drives the core of the
microcontroller, along with all the core system registers,
stacks, and so on.
• I/O Clock (clkIO): This is used by I/O modules —
external interrupts, timers, and serial modules (SPI/USART0).
• Flash Clock (clkFLASH): This controls the Flash memory
• Asynchronous Timer Clock (clkASY): This allows Timer2
to work in asynchronous mode; in other words, it is not linked
to the same clock source as the other clocks, but runs off an
external source. This is a topic we’ll cover at a later stage.
• ADC Clock (clkADC): This clock controls the operation of
the ADC (analog-to-digital converter), allowing it to run in
ADC Noise Reduction mode when other clocks are disabled.
Clocks and Oscillators
Something that I struggled with initially was the
difference between a clock and an oscillator. An oscillator is
a clock source — think of it as your car’s engine. The
oscillator can drive multiple clocks; a bit like when you
engage gear on your car, the engine drives multiple wheels.
Oscillators consume power (small amounts), so you’ll see
that some sleep modes allow you to disable them. The
disadvantage to disabling them is that it takes longer to wake
from sleep (a bit like starting your car engine then engaging
gear, as opposed to simply engaging gear).