Sleep modes or power saving modes present in atamega32 are similar to the sleep modes available in our laptops. Sleep modes enable the application to shut down unused modules in the MCU, thereby saving power. The AVR provides various sleep modes allowing the user to tailor the power consumption to the application’s requirements. The six sleep modes available are :-
A register is basically a storage space of generally 1 byte whose data is used in processing by the MCU. The MCU Control Register contains control bits for power management.
- Idle
- ADC Noise Reduction
- Power-down
- Power-save
- Standby
- Extended Standby
A register is basically a storage space of generally 1 byte whose data is used in processing by the MCU. The MCU Control Register contains control bits for power management.
- Bit 7 – SE: Sleep Enable
The SE bit must be written to logic one to make the MCU enter the sleep mode when the SLEEP instruction is executed. To avoid the MCU entering the sleep mode unless it is the programmers purpose, it is recommended to write the Sleep Enable (SE) bit to one just before the execution of the SLEEP instruction and to clear it immediately after waking up. This can be done by the instruction MCUCR|=(1<<SE);
- Bits 6...4 – SM2..0: Sleep Mode Select Bits 2, 1, and 0
These bits select between the six available sleep modes :-
- Idle Mode - When the SM2..0 bits are written to 000, the SLEEP instruction makes the MCU enter Idle mode, stopping the CPU but allowing SPI, USART, Analog Comparator, ADC, Two-wire Serial Interface, Timer/Counters, Watchdog, and the interrupt system to continue operating. 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. This is done by MCUCR|=(0<<SM0)|(0<<SM1)|(0<<SM2);
- ADC Noise Reduction Mode - When the SM2..0 bits are written to 001, the SLEEP instruction makes the MCU enter ADC Noise Reduction mode, stopping the CPU but allowing the ADC, the External Interrupts, the Two-wire Serial Interface address watch, Timer/Counter2 and the Watchdog to continue operating (if enabled). 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. This is done by MCUCR|=(1<<SM0)|(0<<SM1)|(0<<SM2);
- Power-down Mode - When the SM2..0 bits are written to 010, the SLEEP instruction makes the MCU enter Powerdown mode. In this mode, the External Oscillator is stopped, while the External interrupts, the Two-wire Serial Interface address watch, and the Watchdog continue operating (if enabled). This sleep mode basically halts all generated clocks, allowing operation of asynchronous modules only. 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. This is done by MCUCR|=(0<<SM0)|(1<<SM1)|(0<<SM2); - Power-save Mode - When the SM2..0 bits are written to 011, the SLEEP instruction makes the MCU enter Powersave mode. This mode is identical to Power-down, with one exception: If Timer/Counter2 is clocked asynchronously, i.e., the AS2 bit in ASSR is set, Timer/Counter2 will run 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 TIMSK, and the Global Interrupt Enable bit in SREG is set. This is done by MCUCR|=(1<<SM0)|(1<<SM1)|(0<<SM2);
- Standby Mode - When the SM2..0 bits are 110 and an external crystal/resonator clock option is selected, the SLEEP instruction makes the MCU enter Standby mode. 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. This done by MCUCR|=(0<<SM0)|(1<<SM1)|(1<<SM2);
- Extended Standby Mode - When the SM2..0 bits are 111 and an external crystal/resonator clock option is selected, the SLEEP instruction makes the MCU enter Extended Standby mode. This mode is identical to Power-save mode with the exception that the Oscillator is kept running. From Extended Standby mode, the device wakes up in six clock cycles. This done by MCUCR|=(1<<SM0)|(1<<SM1)|(1<<SM2);
To enter any of the six sleep modes, the SE bit in MCUCR must be written to logic one and a SLEEP instruction must be executed. If an enabled interrupt occurs while the MCU is in a sleep mode, the MCU wakes up. The MCU is then halted for four cycles in addition to the start-up time, it executes the interrupt routine, and resumes execution from the instruction following SLEEP. The contents of the Register File and SRAM are unaltered when the device wakes up from sleep. If a Reset occurs during sleep mode, the MCU wakes up and executes from the Reset Vector.
So friends, that's all for now. Soon be back with another post..
could u plz explain the meaning of the signs in the following instructions :
ReplyDelete* MCUCR|=(1<<SE); SLEEP ENABLE
* MCUCR|=(0<<SM0)|(0<<SM1)|(0<<SM2); IDLE MODE
* MCUCR|=(1<<SM0)|(0<<SM1)|(0<<SM2); ADC NOISE
REDUCTION
* MCUCR|=(0<<SM0)|(1<<SM1)|(0<<SM2); POWER DOWN
* MCUCR|=(1<<SM0)|(1<<SM1)|(0<<SM2); POWER SAVE
* MCUCR|=(0<<SM0)|(1<<SM1)|(1<<SM2); STANDBY
* MCUCR|=(1<<SM0)|(1<<SM1)|(1<<SM2); EXTENDED
STANDBY
SIR IT WOULD BE HIGHLY GREAT IF U WOULD EXPLAIN THE REGISTERS FIRST ALONG WITH THE MEMORY ARCHITECTURE OF ATMEGA
ReplyDeleteI am a bit busy at this time. I'd get to it in a couple of weeks. Plz bear with me..
ReplyDeletehi please help me how i can wake up MCU from POWER DOWN mode i have enabled interrupt 5 and on trigger MCU does not wake , where as it wakes up in IDLE mode
ReplyDeleteLucky 777 Casino - Genting Casino - Cheap Vacation Deals
ReplyDeleteA great casino for 포커 족보 순위 a Las Vegas staycation 10벳 or a vacation, come 우리계열 to the Lucky 블랙 잭 애니 777 프리 벳 Casino. We offer a variety of table games including blackjack, roulette,