Files
Arduino/Sleep_E/Sleep_E.ino
Jérôme Delacotte 7b30d6e298 first commit
2025-03-06 11:15:32 +01:00

45 lines
1.2 KiB
C++
Executable File

//Power Reduction Register (PRR)
//
//
//The next thing to experiment with is the Power Reduction Register
//(PRR). This lets you "turn off" various things inside the processor.
//
//
//The various bits in this register turn off internal devices,
//as follows:
//
//
// Bit 7 - PRTWI: Power Reduction TWI
// Bit 6 - PRTIM2: Power Reduction Timer/Counter2
// Bit 5 - PRTIM0: Power Reduction Timer/Counter0
// Bit 4 - Res: Reserved bit
// Bit 3 - PRTIM1: Power Reduction Timer/Counter1
// Bit 2 - PRSPI: Power Reduction Serial Peripheral Interface
// Bit 1 - PRUSART0: Power Reduction USART0
// Bit 0 - PRADC: Power Reduction ADC
#include <avr/sleep.h>
#include <avr/power.h>
void setup ()
{
// disable ADC
ADCSRA = 0;
// turn off various modules
power_all_disable ();
set_sleep_mode (SLEEP_MODE_IDLE);
noInterrupts (); // timed sequence follows
sleep_enable();
// turn off brown-out enable in software
MCUCR = bit (BODS) | bit (BODSE);
MCUCR = bit (BODS);
interrupts (); // guarantees next instruction executed
sleep_cpu (); // sleep within 3 clock cycles of above
} // end of setup
void loop () { }