📥 RESOURCES & DOWNLOADS
• Atmel Instruction Set: https://drive.google.com/file/d/1pdFA...
• Source from the Example:
– Atomic Instructions, GPIOR, shared flags: https://drive.google.com/file/d/1MHjX...
✏️ EXERCISES
• Reduce the Power Consumption: https://drive.google.com/drive/folder...
🧠 QUIZ
https://forms.gle/f96YxfCPF2q7Y3Uv8
Have you ever needed to run your embedded project on batteries for months or even years? In this section, we explore the power reduction facilities built into the ATmega328P. You will learn how to dramatically reduce power consumption through clock scaling, peripheral deactivation, sleep modes, and intelligent software design that can extend battery life from days to years.
We begin with the relationship between power, voltage, and clock frequency. Power equals current times voltage (P = I × V). At 16MHz/5V the chip draws about 9.5mA (47.5mW), while at 1MHz/3.3V this drops to about 2mW — a 96% reduction.
Runtime clock scaling is explored via the CLKPR (Clock Prescale Register). Unlike fuse-based clock division, CLKPR allows dynamic frequency changes during execution. Prescaler values range from 1 to 256. Important: changing the system clock affects all peripherals, including UART baud rate and ADC timing.
The Power Reduction Register (PRR) allows selective deactivation of unused peripherals: TWI, Timer0/1/2, SPI, USART, and ADC. Leaving all peripherals active wastes about 25% more power than necessary.
Six sleep modes exist with varying power savings: Idle (CPU off, peripherals running), ADC Noise Reduction, Power-save, Power-down, Standby, and Extended Standby. In Power-down mode at 3V, current drops to 250nA — theoretically 228 years on a 500mAh battery.
Wake-up sources depend on sleep depth. Idle mode wakes from any interrupt. Power-down has limited sources: INT0/INT1 level change, TWI address match, and watchdog timer. Standby enables 6-cycle wake-up by keeping the oscillator running.
Energy optimization is analyzed mathematically. Energy = Power × Time. Generally, computing fast and sleeping longer saves more energy because current doesn't scale linearly with frequency. When communication dominates (UART at fixed baud rate), slowing the clock during transmission also saves energy.
Floating pins waste power if their digital input buffers oscillate. The solution: enable internal pull-ups on unused pins to maintain a stable state.
The Watchdog Timer (WDT) provides both system reset capability and periodic wake-up. It runs on an independent 128kHz oscillator, functional in all sleep modes. The WDTCSR register controls mode (interrupt, reset, or both) and timeout (16ms to 8 seconds). Warning: incorrect WDT configuration with old bootloaders can make the chip unprogrammable.
The Brown-Out Detector (BOD) monitors supply voltage and resets the system if it drops below a threshold (1.8V, 2.7V, or 4.3V), set via extended fuse bits. The BOD can be disabled during sleep to save additional power.
General Purpose I/O Registers (GPIOR0-2) provide atomic bit manipulation. Unlike SRAM variables requiring read-modify-write sequences, GPIOR operations compile to single CBI/SBI instructions, eliminating the need for cli/sei wrappers in ISR/main communication.
The MCU Status Register (MCUSR) identifies reset sources: power-on, external, brown-out, or watchdog. Read it early before another reset overwrites it.
Practical demonstrations show power reduction from 35mA (Arduino board at 16MHz/5V) to under 6μA (standalone ATmega in power-down at 3.3V) — a 5000x improvement.
#Arduino #ATmega #PowerReduction #SleepModes #BatteryLife #LowPower #CLKPR #PRR #WatchdogTimer #BrownOutDetector #EmbeddedSystems #EnergyOptimization #GPIOR #PowerDown #Idle
📖 CHAPTERS
0:00 Introduction
2:18 Power Consumption of the ATmega328P
9:16 The Low Fuse
9:59 The Clock Prescaler Register (CLKPR)
14:29 The Power Reduction Register (PRR)
18:57 Sleep Modes and the Sleep Mode Control Register (SCMR)
24:20 Wake-Up Sources
27:19 Slow Clock or Long Sleep? A Question of Energy
35:04 Aligning Computation with Communication
43:35 The sleep_mode() Instruction
47:38 The Atomic Read-Modify-Write Problem
51:51 Sleep in AVR
53:25 The Digital Input Disable Register (DIDR) and Floating Pins
56:15 The Watchdog Timer
1:03:53 The High Fuse
1:06:00 The Brown-Out Detector
1:11:06 Origin of a Reset
1:14:14 Demo of the Exercise (Power Reduction)
1:24:12 Summary and What's next?