Stopping Execution in an Arduino Nano Every

This how-to question was added and quickly removed, but it is a valid question and doesn't appeared to be answered.

On an Arduino Nano Every (or any board using the ATmega4809) you can effectively stop all execution by disabling interrupts and then putting the microcontroller in sleep mode. Add the following line at the top of the file:

#include <avr/sleep.h>

To stop execution, execute:

cli();
sleep_mode();

On chip peripherals will continue to run. They can be turned off if you want to save power.

There’s more to the sleepmodes of the 4809 than this. Some peripherials will continue to run in the different sleepmodes. That said, the cli() prevents the interrupt routines to run, so whatever that peripherial does is irrelevant. Unless all actions go through the Event System, cli() before sleep() turns the board into a brick.

Sure there is more to sleep modes, but that's enough if the goal is to halt the processor until it is reset.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.