en:multiasm:piot:chapter_4_12

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:multiasm:piot:chapter_4_12 [2026/01/10 20:35] pczekalskien:multiasm:piot:chapter_4_12 [2026/01/19 15:16] (current) marcin
Line 10: Line 10:
 To enter any of the sleep modes, the Sleep Enable bit in the Sleep Mode Control Register (SMCR.SE) must be written to '1' and a SLEEP instruction must be executed. Sleep Mode Select bits (SMCR.SM[2:0]) select which sleep mode (Idle, Power-down, Power-save, Standby, or Extended Standby) will be activated by the SLEEP instruction. The sleep modes shown in Fig. {{ref>avr_sleepmodes}} are for the ATmega328PB. To enter any of the sleep modes, the Sleep Enable bit in the Sleep Mode Control Register (SMCR.SE) must be written to '1' and a SLEEP instruction must be executed. Sleep Mode Select bits (SMCR.SM[2:0]) select which sleep mode (Idle, Power-down, Power-save, Standby, or Extended Standby) will be activated by the SLEEP instruction. The sleep modes shown in Fig. {{ref>avr_sleepmodes}} are for the ATmega328PB.
 <figure avr_sleepmodes> <figure avr_sleepmodes>
-{{:en:multiasm:piot:sleep_modes.png?400|ATmega328PB MCU sleep modes}}+{{:en:multiasm:piot:sleep_mode_register.svg?400|ATmega328PB MCU sleep modes}}
 <caption>ATmega328PB MCU sleep modes</caption> <caption>ATmega328PB MCU sleep modes</caption>
 </figure> </figure>
  
 +
 +^  SM2, SM1, SM0  ^  Sleep Mode        ^
 +|  000            |  Idle              |
 +|  001            |                    |
 +|  010            |  Power-down        |
 +|  011            |  Power-save        |
 +|  100            |  Reserved          |
 +|  101            |  Reserved          |
 +|  110            |  Standby           |
 +|  111            |  Extended Standby  |
  
 **Idle Mode** **Idle Mode**
Line 35: Line 45:
 When the SM[2:0] bits are set to '111', and an external clock option is selected, the SLEEP instruction puts the MCU into Extended Standby mode, similar to Power-Save but with the oscillator running. The device wakes up in six clock cycles. When the SM[2:0] bits are set to '111', and an external clock option is selected, the SLEEP instruction puts the MCU into Extended Standby mode, similar to Power-Save but with the oscillator running. The device wakes up in six clock cycles.
  
 +^ Layer                ^ What it does              ^ Your interaction        ^
 +| HAL (Arduino + avr-libc) | Sets SMCR bits for you     | Easy, high-level        |
 +| Assembly (sleep)         | Executes sleep instruction | Uses SMCR settings      |
 +| Hardware (SMCR register) | Controls sleep mode        | Hidden unless accessed manually |
  
  
-AVR® 8-bit microcontrollers include several sleep modes to save power. The AVR device can also lower power consumption by shutting down the clock for select peripherals via a register setting. That register is called the Power Reduction Register (PRR), as presented in figure {{ref>avr_prrdetails}}.+Summary Table: SMCR Differences Across AVR Families 
 + 
 +^ Feature              ^ tinyAVR          ^ megaAVR         ^ XMEGA             ^ 
 +| Register name        | SMCR             | SMCR            | SLEEP.CTRL        | 
 +| Sleep enable bit     | Yes (SE)         | Yes (SE)        | No                | 
 +| Mode bits            | SM1:SM0 (sometimes SM2) | SM2:SM0   | SLEEPMODE1:     | 
 +| Number of modes      | 3–4              | 5–6             | 4                 | 
 +| Power save mode      | Rare             | Yes             | Yes               | 
 +| Standby mode         | Some models      | Yes             | Yes               | 
 +| Extended Standby     | Rare             | Yes             | Yes               | 
 +| Architecture         | Simple           | Standard        | Advanced          | 
 + 
 + 
 + 
 + 
 +AVR® 8-bit microcontrollers include several sleep modes to save power. The AVR device can also lower power consumption by shutting down the clock for select peripherals via a register setting. That register is called the Power Reduction Register (PRR), as presented in Fig. {{ref>avr_prrdetails}}. The Power Reduction Register (PRR) is another place where AVR families differ quite a bit — sometimes even more than SMCR. If SMCR controls how deeply the CPU sleeps, then PRR controls which peripherals are powered at all.
  
 <figure avr_prrdetails> <figure avr_prrdetails>
-{{:en:multiasm:piot:sleep_modes_details.png?400|PRR application details}}+{{:en:multiasm:piot:extended_sleep_mode.svg?400|PRR application details}}
 <caption>PRR application details</caption> <caption>PRR application details</caption>
 </figure> </figure>
  
    
-The PRR provides a runtime method to stop the clock to select individual peripherals. The current state of the peripheral is frozen, and the I/O registers cannot be read or written. Resources used by the peripheral when stopping the clock will remain committed. Hence, the peripheral should, in most cases, be disabled before stopping the clock. Waking up a module, which is done by clearing the bit in PRRputs the module into the same state as before shutdown. +The PRR provides a runtime method to stop the clock to select individual peripherals. The peripheral is currently frozen, and the I/O registers cannot be read or written. Resources used by the peripheral when stopping the clock will remain committed. Hence, the peripheral should, in most cases, be disabled before stopping the clock. Waking up a module by clearing the bit in PRR puts it back into the state it was in before shutdown. 
-The PRR clock shutdown can be used in Idle and Active modes to reduce overall power consumption significantly. In all other sleep modes, the clock is already stopped.+The PRR clock shutdown can be used in Idle and Active modes to significantly reduce overall power consumption. In all other sleep modes, the clock is already stopped. 
 + 
 +PRR Differences Across AVR Families 
 + 
 +^ Feature              ^ tinyAVR                         ^ megaAVR                     ^ XMEGA                                   ^ 
 +| PRR exists           | Sometimes                       | Yes                         | No (replaced by PR.* registers)         | 
 +| Number of registers  | 0–1                             | 1–2                         | Many                                    | 
 +| Peripheral coverage  | Very limited                    | Full                        | Very granular                           | 
 +| Architecture         | Simple                          | Standard                    | Advanced                                | 
 +| Arduino support      | Partial                         | Full                        | None (Arduino doesn’t support XMEGA)   |
  
-Tips to Minimise Power Consumption+Tips to Minimise Power Consumption.
   * Analogue to Digital Converter (ADC): Disable the ADC before entering sleep modes to save power.   * Analogue to Digital Converter (ADC): Disable the ADC before entering sleep modes to save power.
   * Analogue Comparator: Disable the Analogue Comparator in Idle and ADC Noise Reduction modes if not used.   * Analogue Comparator: Disable the Analogue Comparator in Idle and ADC Noise Reduction modes if not used.
en/multiasm/piot/chapter_4_12.1768070138.txt.gz · Last modified: by pczekalski