user38553: Is it possible to change clock speed when running sketch?
Low-power lib drops the current consumption from 20mA to 9.5mA at 8MHz, it is still too much. Is there a way how to set clockspeed (for example) to 1MHz, go to sleep, after interrupt wake up, set clockspeed back to the 8Mhz (for 3v3), do some stuff and then go sleep again?
Thanks

user368: Absolutely. The built-in prescaler can dynamically change the clock speed for most of the systems on the chip (USB still needs to run at full speed in order to operate properly).
#include <avr/power.h>

 ...
clock_prescale_set(clock_div_32);
sleep();
clock_prescale_set(clock_div_1);
 ...

See the datasheet and AVR Libc documentation for more details.

38553: <p>Is it possible to change clock speed when running sketch?</p>

<p>Low-power lib drops the current consumption from 20mA to 9.5mA at 8MHz, it is still too much. Is there a way how to set clockspeed (for example) to 1MHz, go to sleep, after interrupt wake up, set clockspeed back to the 8Mhz (for 3v3), do some stuff and then go sleep again?</p>

<p>Thanks</p>
 368: <p>Absolutely. The built-in prescaler can dynamically change the clock speed for most of the systems on the chip (USB still needs to run at full speed in order to operate properly).</p>

<pre><code>#include &lt;avr/power.h&gt;

 ...
clock_prescale_set(clock_div_32);
sleep();
clock_prescale_set(clock_div_1);
 ...
</code></pre>

<p>See the datasheet and AVR Libc documentation for more details.</p>
