CONFIG POWERMODE
(Created page with "= <span class="f_Header">Action</span> = Put the micro processor in one of the supported power reserving modes. <span style="font-family: Arial;"> </span> <span style=...") |
|||
Line 2: | Line 2: | ||
Put the micro processor in one of the supported power reserving modes. | Put the micro processor in one of the supported power reserving modes. | ||
+ | |||
+ | Config Powermode is for ATTINY, ATMEGA and ATXMEGA devices. | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
Line 9: | Line 11: | ||
= <span class="f_Header">Syntax</span> = | = <span class="f_Header">Syntax</span> = | ||
− | <span style="font-weight: bold; color: rgb(0, 0, 128);"> | + | <span class="f_Syntax">CONFIG POWERMODE</span><span style="font-weight: bold; color: rgb(0, 0, 128);"> = </span>mode |
+ | |||
+ | <span class="f_Header"> </span> | ||
+ | |||
+ | = <span class="f_Header">Example</span> = | ||
+ | |||
+ | <span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';"> Powermode </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Powerdown</span> | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
+ | |||
+ | or | ||
+ | |||
+ | <span style="font-family: Arial;"> </span> | ||
+ | |||
+ | <span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">CONFIG POWERMODE = IDLE</span> | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
Line 19: | Line 33: | ||
The mode depends on the micro processor. | The mode depends on the micro processor. | ||
− | Some valid options | + | Some valid options for <span style="text-decoration: underline;">ATTINY</span> and <span style="text-decoration: underline;">ATMEGA</span> are : |
- IDLE | - IDLE | ||
Line 33: | Line 47: | ||
| | ||
− | The modes and their exact behaviour is different on all processors. The following description from the | + | Valid option for <span style="text-decoration: underline;">ATXMEGA</span> are: |
+ | |||
+ | <span style="font-family: Arial;">- Idle</span> | ||
+ | |||
+ | <span style="font-family: Arial;">- PowerDown</span> | ||
+ | |||
+ | <span style="font-family: Arial;">- PowerSave</span> | ||
+ | |||
+ | <span style="font-family: Arial;">- Standby</span> | ||
+ | |||
+ | <span style="font-family: Arial;">- ExStandby</span> | ||
+ | |||
+ | | ||
+ | |||
+ | The modes and their exact behaviour is different on all processors. The following description from the data sheet is for the Mega88P. | ||
+ | |||
+ | | ||
+ | |||
+ | Keep in mind that you can only achieve the low current consumption of ATTINY and ATMEGA in PowerDown mode when you also consider the "MINIMIZING POWER CONSUMPTION" | ||
+ | |||
+ | section in the data sheet like: | ||
+ | |||
+ | <span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span> | ||
+ | |||
+ | <span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' 1. Disable/Switch off ADC</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' 2. Disable/Switch off Analog Comparator</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' 3. Disable Brown-out Detection when not needed</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' 4. Disable internal voltage reference</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' 5. Disable Watchdog Timer when not needed</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' 6. Disable the digital input buffer</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' 7. Enable Pull-up or pull-down an all unused pins</span> | ||
+ | |||
+ | <span style="font-family: 'Courier New';"> </span> | ||
+ | |||
+ | | ||
+ | |||
+ | In case of ATXMEGA see also [[CONFIG_POWER_REDUCTION|CONFIG POWER_REDUCTION]] to reduce the power consuption in all modes. | ||
+ | |||
+ | | ||
+ | |||
+ | [[File:Notice.jpg|notice]]<span class="f_ImageCaption"> </span>If you measure the current consumption not between the LDO and AVR don't forget to use Low Quiescent Current LDO for example MCP1700, AS1375 or TPS78233 to really get close to the current consumption in the data sheet. | ||
+ | |||
+ | <span class="f_ImageCaption"> </span> | ||
+ | |||
+ | [[File:Notice.jpg|notice]]<span class="f_ImageCaption"> </span>You can also minimize power consumption by keeping the clock frequency as low as possible if sleep modes are not used. | ||
+ | |||
+ | | ||
+ | |||
+ | = <span class="f_Header">Wake up from Sleep Modes</span> = | ||
+ | |||
+ | In the AVR data sheets you find under the sleep modes the <span style="font-weight: bold;">wake up sources</span> for sleep modes. | ||
+ | |||
+ | | ||
+ | |||
+ | For example for an ATTINY25/45/85. The only wake up Sources from PowerDown are: | ||
+ | <div style="padding: 0px; margin: 0px;"> | ||
+ | {| border="0" cellpadding="0" cellspacing="0" | ||
+ | |- valign="baseline" style="vertical-align: baseline;" | ||
+ | | width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span> | ||
+ | | INT0 and Pin Change (For INT0, only level interrupt) | ||
+ | |} | ||
+ | </div><div style="padding: 0px; margin: 0px;"> | ||
+ | {| border="0" cellpadding="0" cellspacing="0" | ||
+ | |- valign="baseline" style="vertical-align: baseline;" | ||
+ | | width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span> | ||
+ | | USI Start Condition | ||
+ | |} | ||
+ | </div><div style="padding: 0px; margin: 0px;"> | ||
+ | {| border="0" cellpadding="0" cellspacing="0" | ||
+ | |- valign="baseline" style="vertical-align: baseline;" | ||
+ | | width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span> | ||
+ | | Watchdog Interrupt | ||
+ | |} | ||
+ | </div> | ||
+ | | ||
+ | |||
+ | The wake up sources for an ATXMEGA32A4U from powerdown are: | ||
+ | <div style="padding: 0px; margin: 0px;"> | ||
+ | {| border="0" cellpadding="0" cellspacing="0" | ||
+ | |- valign="baseline" style="vertical-align: baseline;" | ||
+ | | width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span> | ||
+ | | USB Resume | ||
+ | |} | ||
+ | </div><div style="padding: 0px; margin: 0px;"> | ||
+ | {| border="0" cellpadding="0" cellspacing="0" | ||
+ | |- valign="baseline" style="vertical-align: baseline;" | ||
+ | | width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span> | ||
+ | | Asynchronous Port Interrupts | ||
+ | |} | ||
+ | </div><div style="padding: 0px; margin: 0px;"> | ||
+ | {| border="0" cellpadding="0" cellspacing="0" | ||
+ | |- valign="baseline" style="vertical-align: baseline;" | ||
+ | | width="13" | <span style="font-size: 10pt; font-family: 'Arial Unicode MS', 'Lucida Sans Unicode', Arial;">•</span> | ||
+ | | TWI Address Match Interrupts | ||
+ | |} | ||
+ | </div> | ||
+ | | ||
+ | |||
+ | Asynchronous pin-change sensing with ATXMEGA means that a pin change can wake the device from all sleep modes, included the modes where | ||
+ | |||
+ | no clocks are running (Synchronous sensing requires the presence of the peripheral clock, while asynchronous sensing does not require any | ||
+ | |||
+ | clock.) | ||
+ | |||
+ | See also: [[ATXMEGA]] | ||
+ | |||
+ | | ||
+ | |||
+ | You will find an example below with ATXMEGA, PowerDown and Wake up from asynchronous Port Pin. | ||
+ | |||
+ | | ||
+ | |||
+ | = <span class="f_Header">Example for Powerdown with ATXMEGA</span> = | ||
+ | |||
+ | <span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$regfile</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"XM256A3BUDEF.DAT"</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$crystal</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> 32000000 </span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'32MHz</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$hwstack</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> 64</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$swstack</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> 40</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$framesize</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> 80</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';"> Osc </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> Enabled </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> 32mhzosc </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> Enabled</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';"> Sysclock </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> 32mhz </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Prescalea </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> 1 </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Prescalebc </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> 1_1</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';"> Power_reduction </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> Dummy </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Aes </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Twic </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Twid </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Twie </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Aca </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Adcb </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Tcc0 </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';">Tcc1 </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Dma </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Here you have 5 seconds to measure the current consumption with multi meter</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">wait</span><span style="font-family: 'Courier New';"> 5</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';"> Powermode </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Powerdown</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">End</span> | ||
+ | |||
+ | <span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);"> </span> | ||
+ | |||
+ | = <span class="f_Header">Example with ATXMEGA, PowerDown and Wake up from asynchronous Port Pin.</span> = | ||
+ | |||
+ | <span class="f_Header"> </span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' The following example give you 5 seconds to measure the current in active mode</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Then you have time to measure the current in PowerDown mode</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' after this you can wake up the XMEGA from PowerDown with Portf.2 until the ATXMEGA will</span> | ||
+ | |||
+ | <span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' go to PowerDown mode again after 5 seconds</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' The hardware used for this example is XMEGA-A3BU Xplained board from ATMEL</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$regfile</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(0, 128, 128);">"XM256A3BUDEF.DAT"</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$crystal</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> 32000000 </span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'32MHz</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$hwstack</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> 64</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$swstack</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> 40</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">$framesize</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> 80</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';"> Osc </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> Enabled </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> 32mhzosc </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> Enabled</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';"> Sysclock </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> 32mhz </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Prescalea </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> 1 </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Prescalebc </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> 1_1</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';"> Power_reduction </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> Dummy </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Aes </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Twic </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Twid </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Twie </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Aca </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Adcb </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Tcc0 </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';">Tcc1 </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Dma </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Off</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Priority</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> Static </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Vector </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> Application </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Lo </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> Enabled </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Med </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> Enabled </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Hi </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> Enabled</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'When a button is pressed it will drive the I/O line to GND.</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'We use SW2 (Switch 2) on the A3BU XPLAINED Board</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'This Switch is connected to PortF.2 which is an asynchronous Pin (Every Pin 2 is an asynchronous pin)</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Other Pins can also wake up the XMEGA but only "Both Edges" and "Low Level is supported and in addition the</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">'Pin value must be kept unchanged during wake up</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">On</span><span style="font-family: 'Courier New';"> Portf_int0 Wake_up</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Enable</span><span style="font-family: 'Courier New';"> Portf_int0 </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Hi</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portf</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">2 </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Input</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';"> Xpin </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portf</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">.</span><span style="font-family: 'Courier New';">2 </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">,</span><span style="font-family: 'Courier New';"> Sense </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> Falling</span><br/><span style="font-family: 'Courier New'; color: rgb(128, 0, 0);">Portf_int0mask</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">&</span><span style="font-family: 'Courier New';">B0000_0100 </span><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Assign pin F2</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Enable</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Interrupts</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Do</span><br/><span style="font-family: 'Courier New'; color: rgb(0, 128, 0);">' Here you have 5 seconds to measure the current consumption with multi meter</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">wait</span><span style="font-family: 'Courier New';"> 5</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-family: 'Courier New';"> Powermode </span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">=</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Powerdown</span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Loop</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">End</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New';">Wake_up</span><span style="font-family: 'Courier New'; color: rgb(255, 0, 0);">:</span><br/><span style="font-family: 'Courier New';"> </span><br/><span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);">Return</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);"> </span> | ||
| | ||
− | = <span class="f_Header">IDLE MODE</span> = | + | = <span class="f_Header">IDLE MODE (ATMEGA88)</span> = |
<span style="font-family: Helvetica;">The Idle mode will stop the CPU but allowing the SPI, USART, Analog Comparator, ADC, 2-wire Serial</span> | <span style="font-family: Helvetica;">The Idle mode will stop the CPU but allowing the SPI, USART, Analog Comparator, ADC, 2-wire Serial</span> | ||
Line 59: | Line 189: | ||
| | ||
− | = <span class="f_Header">ADC NOISE REDUCTION</span> = | + | = <span class="f_Header">ADC NOISE REDUCTION (ATMEGA88)</span> = |
<span style="font-family: Helvetica;">This mode will stop the CPU but allowing the ADC, the external interrupts, the 2-</span> | <span style="font-family: Helvetica;">This mode will stop the CPU but allowing the ADC, the external interrupts, the 2-</span> | ||
Line 83: | Line 213: | ||
| | ||
− | = <span class="f_Header">POWERDOWN</span> = | + | = <span class="f_Header">POWERDOWN (ATMEGA88)</span> = |
<span style="font-family: Helvetica;">In this mode, the external Oscillator is stopped, while the external interrupts, the 2-</span> | <span style="font-family: Helvetica;">In this mode, the external Oscillator is stopped, while the external interrupts, the 2-</span> | ||
Line 111: | Line 241: | ||
| | ||
− | = <span class="f_Header">POWERSAVE</span> = | + | = <span class="f_Header">POWERSAVE (ATMEGA88)</span> = |
<span style="font-family: Helvetica;">This mode is identical to Power-down, with one exception:</span> | <span style="font-family: Helvetica;">This mode is identical to Power-down, with one exception:</span> | ||
Line 139: | Line 269: | ||
| | ||
− | = <span class="f_Header">STANDBY</span> = | + | = <span class="f_Header">STANDBY (ATMEGA88)</span> = |
<span style="font-family: Helvetica;">This mode is identical to Power-down</span> | <span style="font-family: Helvetica;">This mode is identical to Power-down</span> | ||
Line 151: | Line 281: | ||
<span style="font-family: Helvetica;"> </span> | <span style="font-family: Helvetica;"> </span> | ||
− | = <span class="f_Header">EXTENDED STANDBY</span> = | + | = <span class="f_Header">EXTENDED STANDBY</span><span class="f_Header"> (ATMEGA88)</span> = |
<span style="font-family: Helvetica;">This mode is identical to</span> | <span style="font-family: Helvetica;">This mode is identical to</span> | ||
Line 163: | Line 293: | ||
| | ||
− | So for standby you would use | + | So for standby you would use : POWER STANDBY |
It is also possible to use POWERDOWN, IDLE or POWERSAVE. These modes were/are supported by most processors. It is recommended to use the new CONFIG POWERMODE command because it allows to use more modes. | It is also possible to use POWERDOWN, IDLE or POWERSAVE. These modes were/are supported by most processors. It is recommended to use the new CONFIG POWERMODE command because it allows to use more modes. | ||
Line 175: | Line 305: | ||
= <span class="f_Header">See also</span> = | = <span class="f_Header">See also</span> = | ||
− | <span style="font-family: Arial;">[[IDLE]], [[POWERDOWN]] , [[POWERSAVE]]</span> | + | <span style="font-family: Arial;">[[IDLE]], [[POWERDOWN]] , [[POWERSAVE]], [[CONFIG_POWER_REDUCTION|CONFIG POWER_REDUCTION]]</span> |
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
Line 181: | Line 311: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | = <span class="f_Header">Example</span> = | + | <span style="font-family: 'Courier New'; font-weight: bold; color: rgb(0, 0, 128);"> </span> |
+ | |||
+ | = <span class="f_Header">Example for Powerdown and wake up with ATTINY</span> = | ||
+ | |||
+ | <span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Using the new config powermode = PowerDown function with ATTINY13</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Fuse Bits:</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Disable DWEN (Debug Wire) Fuse Bit</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Disable Brown-Out Detection in Fuse Bits</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Disable Watchdog in Fuse Bits</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' You can also just use Config Powermode = Powerdown</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' But this example here also considers what the data sheet write under "MINIMIZING POWER CONSUMPTION"</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' You need to follow this when you want to achieve the current consumption which you find in the data sheet under Powerdown Mode</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' 1. Disable/Switch off ADC</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' 2. Disable/Switch off Analog Comparator</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' 3. Disable Brown-out Detection when not needed</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' 4. Disable internal voltage reference</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' 5. Disable Watchdog Timer when not needed</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' 6. Disable the digital input buffer</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' 7. Enable Pull-up or pull-down an all unused pins</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$regfile</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"attiny13.dat"</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$crystal</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 9600000 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'9.6MHz</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$hwstack</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 10</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$swstack</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 0</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$framesize</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 24</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">On</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Int0</span><span style="font-size: 8pt; font-family: Courier;"> Int0_isr </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'INT0 will be the wake-up source for Powerdown Mode</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Int0</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Low</span><span style="font-size: 8pt; font-family: Courier;"> Level</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Enable</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Int0</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Prepare Powerdown:</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' To minimize power consumption, enable pull-up or -down on all unused pins, and</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' disable the digital input buffer on pins that are connected to analog sources</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Portb</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">0 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Input</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Set</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Portb</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">0</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Portb</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">1 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Input</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'INT0 --> external 47K pull-up</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Set Portb.1</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Portb</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">2 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Input</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Set</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Portb</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">2</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Portb</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">3 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Input</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Set</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Portb</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">3</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Portb</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">4 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Input</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Set</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Portb</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">4</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Portb</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier;">5 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Input</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'External Pull-Up (Reset)</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Didr0</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Bits</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">(</span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">ain1d</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">,</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Ain0d</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">)</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Disable digital input buffer on the AIN1/0 pin</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Set</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Acsr</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">acd</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Switch off the power to the Analog Comparator</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'alternative:</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Stop Ac</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Reset</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Acsr</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">acbg</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Disable Analog Comparator Bandgap Select</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Reset</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Adcsra</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">.</span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">aden</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Switch off ADC</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'alternative:</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Stop Adc</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'###############################################################################</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Do</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Wait</span><span style="font-size: 8pt; font-family: Courier;"> 3 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' now we have 3 second to measure the Supply Current in Active Mode</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Enable</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Interrupts</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Now call Powerdown function</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> Powermode </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Powerdown</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Here you have time to measure PowerDown current consumption until a Low Level on Portb.1 which is the PowerDown wake-up</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Loop</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'###############################################################################</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">End</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;">Int0_isr</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">:</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' wake_up</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Return</span> | ||
+ | |||
+ | <span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);"> </span> | ||
+ | |||
+ | <span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);"> </span> | ||
+ | |||
+ | = <span class="f_Header">Example for Idle and wake up with ATTINY</span> = | ||
+ | |||
+ | <span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);"> </span> | ||
+ | |||
+ | <span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Using the new config powermode = Idle function with ATTINY13</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Idle: This sleep mode basically halts clkCPU and clkFLASH, while allowing the other clocks to run.</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Fuse Bits:</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Disable DWEN (Debug Wire) Fuse Bit</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Disable Brown-Out Detection in Fuse Bits</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Disable Watchdog in Fuse Bits</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$regfile</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 128);">"attiny13.dat"</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$crystal</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 1200000 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'1.2MHz (9.6MHz/DIV8 = 1.2MHz)</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$hwstack</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 10</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$swstack</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 0</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">$framesize</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> 24</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">On</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Int0</span><span style="font-size: 8pt; font-family: Courier;"> Int0_isr </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'INT0 will be the wake-up source for Idle Mode</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Int0</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Low</span><span style="font-size: 8pt; font-family: Courier;"> Level</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Enable</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);">Int0</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(128, 0, 0);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'###############################################################################</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Do</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Wait</span><span style="font-size: 8pt; font-family: Courier;"> 3 </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' now we have 3 second to measure the Supply Current in Active Mode</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Enable</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Interrupts</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' Now call Idle function</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Config</span><span style="font-size: 8pt; font-family: Courier;"> Powermode </span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">=</span><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Idle</span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'Here you have time to measure Idle current consumption until a Low Level on Portb.1 which is the Idle wake-up</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Loop</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">'###############################################################################</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">End</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);"> </span><br/><span style="font-size: 8pt; font-family: Courier;"> </span><br/><span style="font-size: 8pt; font-family: Courier;">Int0_isr</span><span style="font-size: 8pt; font-family: Courier; color: rgb(255, 0, 0);">:</span><br/><span style="font-size: 8pt; font-family: Courier; color: rgb(0, 128, 0);">' wake_up</span><br/><span style="font-size: 8pt; font-family: Courier; font-weight: bold; color: rgb(0, 0, 128);">Return</span> | ||
+ | |||
+ | <span class="f_Header"> </span> | ||
− | + | <source lang="bascomavr"> | |
CONFIG POWERMODE = IDLE | CONFIG POWERMODE = IDLE | ||
</source><br/>{{Languages}} | </source><br/>{{Languages}} | ||
[[Category:BASCOM Language Reference]] | [[Category:BASCOM Language Reference]] |
Revision as of 21:02, 24 August 2013
Action
Put the micro processor in one of the supported power reserving modes.
Config Powermode is for ATTINY, ATMEGA and ATXMEGA devices.
Syntax
CONFIG POWERMODE = mode
Example
Config Powermode = Powerdown
or
CONFIG POWERMODE = IDLE
Remarks
The mode depends on the micro processor.
Some valid options for ATTINY and ATMEGA are :
- IDLE
- POWERDOWN
- STANDBY
- ADCNOISE
- POWERSAVE
Valid option for ATXMEGA are:
- Idle
- PowerDown
- PowerSave
- Standby
- ExStandby
The modes and their exact behaviour is different on all processors. The following description from the data sheet is for the Mega88P.
Keep in mind that you can only achieve the low current consumption of ATTINY and ATMEGA in PowerDown mode when you also consider the "MINIMIZING POWER CONSUMPTION"
section in the data sheet like:
' 1. Disable/Switch off ADC
' 2. Disable/Switch off Analog Comparator
' 3. Disable Brown-out Detection when not needed
' 4. Disable internal voltage reference
' 5. Disable Watchdog Timer when not needed
' 6. Disable the digital input buffer
' 7. Enable Pull-up or pull-down an all unused pins
In case of ATXMEGA see also CONFIG POWER_REDUCTION to reduce the power consuption in all modes.
If you measure the current consumption not between the LDO and AVR don't forget to use Low Quiescent Current LDO for example MCP1700, AS1375 or TPS78233 to really get close to the current consumption in the data sheet.
You can also minimize power consumption by keeping the clock frequency as low as possible if sleep modes are not used.
Wake up from Sleep Modes
In the AVR data sheets you find under the sleep modes the wake up sources for sleep modes.
For example for an ATTINY25/45/85. The only wake up Sources from PowerDown are:
• | INT0 and Pin Change (For INT0, only level interrupt) |
• | USI Start Condition |
• | Watchdog Interrupt |
The wake up sources for an ATXMEGA32A4U from powerdown are:
• | USB Resume |
• | Asynchronous Port Interrupts |
• | TWI Address Match Interrupts |
Asynchronous pin-change sensing with ATXMEGA means that a pin change can wake the device from all sleep modes, included the modes where
no clocks are running (Synchronous sensing requires the presence of the peripheral clock, while asynchronous sensing does not require any
clock.)
See also: ATXMEGA
You will find an example below with ATXMEGA, PowerDown and Wake up from asynchronous Port Pin.
Example for Powerdown with ATXMEGA
$regfile = "XM256A3BUDEF.DAT"
$crystal = 32000000 '32MHz
$hwstack = 64
$swstack = 40
$framesize = 80
Config Osc = Enabled , 32mhzosc = Enabled
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
Config Power_reduction = Dummy , Aes = Off , Twic = Off , Twid = Off , Twie = Off , Aca = Off , Adcb = Off , Tcc0 = Off ,Tcc1 = Off , Dma = Off
' Here you have 5 seconds to measure the current consumption with multi meter
wait 5
Config Powermode = Powerdown
End
Example with ATXMEGA, PowerDown and Wake up from asynchronous Port Pin.
' The following example give you 5 seconds to measure the current in active mode
' Then you have time to measure the current in PowerDown mode
' after this you can wake up the XMEGA from PowerDown with Portf.2 until the ATXMEGA will
' go to PowerDown mode again after 5 seconds
' The hardware used for this example is XMEGA-A3BU Xplained board from ATMEL
$regfile = "XM256A3BUDEF.DAT"
$crystal = 32000000 '32MHz
$hwstack = 64
$swstack = 40
$framesize = 80
Config Osc = Enabled , 32mhzosc = Enabled
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
Config Power_reduction = Dummy , Aes = Off , Twic = Off , Twid = Off , Twie = Off , Aca = Off , Adcb = Off , Tcc0 = Off ,Tcc1 = Off , Dma = Off
Config Priority = Static , Vector = Application , Lo = Enabled , Med = Enabled , Hi = Enabled
'When a button is pressed it will drive the I/O line to GND.
'We use SW2 (Switch 2) on the A3BU XPLAINED Board
'This Switch is connected to PortF.2 which is an asynchronous Pin (Every Pin 2 is an asynchronous pin)
'Other Pins can also wake up the XMEGA but only "Both Edges" and "Low Level is supported and in addition the
'Pin value must be kept unchanged during wake up
On Portf_int0 Wake_up
Enable Portf_int0 , Hi
Config Portf.2 = Input
Config Xpin = Portf.2 , Sense = Falling
Portf_int0mask = &B0000_0100 ' Assign pin F2
Enable Interrupts
Do
' Here you have 5 seconds to measure the current consumption with multi meter
wait 5
Config Powermode = Powerdown
Loop
End
Wake_up:
Return
IDLE MODE (ATMEGA88)
The Idle mode will stop the CPU but allowing the SPI, USART, Analog Comparator, ADC, 2-wire Serial
Interface, Timer/Counters, Watchdog, and the interrupt system to continue operating. This sleep
mode basically halts clkCPU and clkFLASH, while allowing the other clocks to run.
Idle mode enables the MCU to wake up from external triggered interrupts as well as internal
ones like the Timer Overflow and USART Transmit Complete interrupts. If wake-up from the
Analog Comparator interrupt is not required, the Analog Comparator can be powered down by
setting the ACD bit in the Analog Comparator Control and Status Register – ACSR. This will
reduce power consumption in Idle mode. If the ADC is enabled, a conversion starts automatically
when this mode is entered.
ADC NOISE REDUCTION (ATMEGA88)
This mode will stop the CPU but allowing the ADC, the external interrupts, the 2-
wire Serial Interface address watch, Timer/Counter2(1), and the Watchdog to continue operating
(if enabled). This sleep mode basically halts clkI/O, clkCPU, and clkFLASH, while allowing the other
clocks to run.
This improves the noise environment for the ADC, enabling higher resolution measurements. If
the ADC is enabled, a conversion starts automatically when this mode is entered. Apart from the
ADC Conversion Complete interrupt, only an External Reset, a Watchdog System Reset, a
Watchdog Interrupt, a Brown-out Reset, a 2-wire Serial Interface address match, a
Timer/Counter2 interrupt, an SPM/EEPROM ready interrupt, an external level interrupt on INT0
or INT1 or a pin change interrupt can wake up the MCU from ADC Noise Reduction mode.
POWERDOWN (ATMEGA88)
In this mode, the external Oscillator is stopped, while the external interrupts, the 2-
wire Serial Interface address watch, and the Watchdog continue operating (if enabled). Only an
External Reset, a Watchdog System Reset, a Watchdog Interrupt, a Brown-out Reset, a 2-wire
Serial Interface address match, an external level interrupt on INT0 or INT1, or a pin change
interrupt can wake up the MCU. This sleep mode basically halts all generated clocks, allowing
operation of asynchronous modules only.
Note that if a level triggered interrupt is used for wake-up from Power-down mode, the changed
level must be held for some time to wake up the MCU.
When waking up from Power-down mode, there is a delay from the wake-up condition occurs
until the wake-up becomes effective. This allows the clock to restart and become stable after
having been stopped. The wake-up period is defined by the same CKSEL Fuses that define the
Reset Time-out period, as described in ”Clock Sources”
POWERSAVE (ATMEGA88)
This mode is identical to Power-down, with one exception:
If Timer/Counter2 is enabled, it will keep running during sleep. The device can wake up from
either Timer Overflow or Output Compare event from Timer/Counter2 if the corresponding
Timer/Counter2 interrupt enable bits are set in TIMSK2, and the Global Interrupt Enable bit in
SREG is set.
If Timer/Counter2 is not running, Power-down mode is recommended instead of Power-save
mode.
The Timer/Counter2 can be clocked both synchronously and asynchronously in Power-save
mode. If Timer/Counter2 is not using the asynchronous clock, the Timer/Counter Oscillator is
stopped during sleep. If Timer/Counter2 is not using the synchronous clock, the clock source is
stopped during sleep. Note that even if the synchronous clock is running in Power-save, this
clock is only available for Timer/Counter2.
STANDBY (ATMEGA88)
This mode is identical to Power-down
with the exception that the Oscillator is kept running. From Standby mode, the device wakes up
in six clock cycles.
EXTENDED STANDBY (ATMEGA88)
This mode is identical to
Power-save with the exception that the Oscillator is kept running. From Extended Standby
mode, the device wakes up in six clock cycles.
So for standby you would use : POWER STANDBY
It is also possible to use POWERDOWN, IDLE or POWERSAVE. These modes were/are supported by most processors. It is recommended to use the new CONFIG POWERMODE command because it allows to use more modes.
See also
IDLE, POWERDOWN , POWERSAVE, CONFIG POWER_REDUCTION
Example for Powerdown and wake up with ATTINY
' Using the new config powermode = PowerDown function with ATTINY13
' Fuse Bits:
' Disable DWEN (Debug Wire) Fuse Bit
' Disable Brown-Out Detection in Fuse Bits
' Disable Watchdog in Fuse Bits
' You can also just use Config Powermode = Powerdown
' But this example here also considers what the data sheet write under "MINIMIZING POWER CONSUMPTION"
' You need to follow this when you want to achieve the current consumption which you find in the data sheet under Powerdown Mode
' 1. Disable/Switch off ADC
' 2. Disable/Switch off Analog Comparator
' 3. Disable Brown-out Detection when not needed
' 4. Disable internal voltage reference
' 5. Disable Watchdog Timer when not needed
' 6. Disable the digital input buffer
' 7. Enable Pull-up or pull-down an all unused pins
$regfile = "attiny13.dat"
$crystal = 9600000 '9.6MHz
$hwstack = 10
$swstack = 0
$framesize = 24
On Int0 Int0_isr 'INT0 will be the wake-up source for Powerdown Mode
Config Int0 = Low Level
Enable Int0
' Prepare Powerdown:
' To minimize power consumption, enable pull-up or -down on all unused pins, and
' disable the digital input buffer on pins that are connected to analog sources
Config Portb.0 = Input
Set Portb.0
Config Portb.1 = Input 'INT0 --> external 47K pull-up
'Set Portb.1
Config Portb.2 = Input
Set Portb.2
Config Portb.3 = Input
Set Portb.3
Config Portb.4 = Input
Set Portb.4
Config Portb.5 = Input 'External Pull-Up (Reset)
Didr0 = Bits(ain1d , Ain0d) 'Disable digital input buffer on the AIN1/0 pin
Set Acsr.acd 'Switch off the power to the Analog Comparator
'alternative:
' Stop Ac
Reset Acsr.acbg 'Disable Analog Comparator Bandgap Select
Reset Adcsra.aden 'Switch off ADC
'alternative:
' Stop Adc
'###############################################################################
Do
Wait 3 ' now we have 3 second to measure the Supply Current in Active Mode
Enable Interrupts
' Now call Powerdown function
Config Powermode = Powerdown
'Here you have time to measure PowerDown current consumption until a Low Level on Portb.1 which is the PowerDown wake-up
Loop
'###############################################################################
End
Int0_isr:
' wake_up
Return
Example for Idle and wake up with ATTINY
' Using the new config powermode = Idle function with ATTINY13
' Idle: This sleep mode basically halts clkCPU and clkFLASH, while allowing the other clocks to run.
' Fuse Bits:
' Disable DWEN (Debug Wire) Fuse Bit
' Disable Brown-Out Detection in Fuse Bits
' Disable Watchdog in Fuse Bits
$regfile = "attiny13.dat"
$crystal = 1200000 '1.2MHz (9.6MHz/DIV8 = 1.2MHz)
$hwstack = 10
$swstack = 0
$framesize = 24
On Int0 Int0_isr 'INT0 will be the wake-up source for Idle Mode
Config Int0 = Low Level
Enable Int0
'###############################################################################
Do
Wait 3 ' now we have 3 second to measure the Supply Current in Active Mode
Enable Interrupts
' Now call Idle function
Config Powermode = Idle
'Here you have time to measure Idle current consumption until a Low Level on Portb.1 which is the Idle wake-up
Loop
'###############################################################################
End
Int0_isr:
' wake_up
Return
CONFIG POWERMODE = IDLE
Languages | English • Deutsch |
---|