A Deep Dive into Deep Sleep
How does deep sleep work? A clock signal is used to prompt a microprocessor to process tasks. Without this clock, the microprocessor comes to a standstill and stops using power almost completely. However, the processor requires a clock signal to initiate a wake-up call. To prevent the clock from stopping entirely, (which would prevent us from waking the end device up again), we need a work-around.
Deep Sleep Processes
The clock signal structure in a microprocessor starts at the oscillator. The clock signal from the oscillator is passed on to the global clock (GCLK), which provides the clock signal to the CPU core, power manager, and peripherals.
Why is a clock so important for power use? The answer lies with the power consumption of the clock itself, as well as with the power consumption that occurs because of the clock. Clocks are usually rated at a current draw per MHz. The current draw has a linear correlation with the frequency of the clock. A clock requires 24 times more power when running at 48 MHz than it does when running at 2 MHz. In order to initiate sleep, the clock operates at the lowest frequency possible (usually a 32.768 kHz clock that is designed for low power rather than high accuracy). This means that the processor comes to a standstill, with the interrupt controller monitoring the clock signal and interrupts. Hence, the microprocessor shuts down almost entirely and goes into deep sleep. However, in some cases, lighter sleep may be initiated where a higher-frequency clock is kept active (1MHz for example).
After the device is asleep, it has to be able to wake up again; otherwise, there is no point in putting it to sleep in the first place. Waking up the processor generally depends on the sleep mode of the end device. In almost all scenarios, waking up the processor on the end device requires an interrupt. This can be any interrupt on a physical pin, for example a button being pushed, or an interrupt generated by an internal peripheral (such as a timer that triggers at a predefined interval).