Idle mode and sleep mode of STC12 series microcontrollers

Publisher:以泉换泉Latest update time:2013-12-27 Source: 21ic Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Idle mode

Idle mode refers to the state where only the microcontroller is not working. At this time, the CPU has no clock and stops working, but the external interrupt, external low voltage detection circuit, timer, A/D conversion, serial port, etc. are still running normally.

In idle mode, the RAM, stack pointer (SP), program counter (PC), program status word (PSW), accumulator (A) and other registers retain their original data. The I/O ports retain the logical state before the idle mode is activated.

At this time, all peripheral devices of the microcontroller can operate normally. When any interrupt occurs, they can wake up the microcontroller. After the microcontroller is woken up, the CPU will continue to execute the next instruction of the idle mode statement.

How do I exit idle mode?

a. Interrupt: Any interrupt will cause IDL/PCON.0 to be cleared by hardware, thus exiting the idle mode;

b. External RST pin reset: Pull the reset pin high to generate a reset. Then pull the RST pin low to end the reset, and the MCU will start working normally from 0000H of the user program.

What is the purpose of idle mode?

 The purpose of putting the microcontroller into idle mode is usually to reduce the power consumption of the system. For example, everyone has used a digital multimeter. When it is in normal use, the microcontroller inside the meter is in normal working mode. When it is not in use, the power of the multimeter is forgotten to be turned off. Most meters will automatically turn off the LCD display after waiting for a few minutes without human operation to reduce system power consumption. Usually, the implementation of such functions uses the idle mode or power-down mode of the microcontroller. Taking the STC89 series microcontroller as an example, the power consumption of the microcontroller is usually 4mA to 7mA when it is working normally. When it enters the idle mode, its power consumption drops to 2mA. When it enters the power-down mode, the power consumption can be reduced to less than 0.1μA.

2. Sleep mode (also called power-down mode, stop mode)
When the MCU enters power-down mode, the external crystal oscillator stops, the CPU, timer, and serial port all stop working, and only the external interrupt continues to work. The instruction that puts the MCU into sleep mode will become the last instruction executed by the MCU before sleep. After entering sleep mode, the data in the data memory and special function registers not involved in the program in the chip will maintain the original value. The MCU can be awakened by an external interrupt low level trigger, a falling edge trigger interrupt, or a hardware reset mode. It should be noted that when the interrupt is used to wake up the MCU, the program continues to run from the original stop point. When the hardware reset is used to wake up the MCU, the program will start from the beginning.

How do I exit sleep mode?

a. The external pins that can wake up the CPU from sleep mode are: external interrupt 0, external interrupt 1, timer 0, timer 1, RxD, PWM0/PCA0/P3.7, PWM2/PCA2/P2.0, PWM3/PCA3/P2.4

b. External reset can also wake up the MCU from power-down mode. After reset, the MCU will start working normally from 0000H of the user program.

The power management register PCON controls the microcontroller to enter idle mode and sleep mode. The lowest two bits of this register, IDL and PD, are used to set whether the microcontroller enters idle mode and power-down mode respectively.

Set IDL/PCON.0 to 1, and the microcontroller enters the IDLE mode.

Set PD/PCON.1 to 1, and the microcontroller will enter the power down mode.

For more detailed information, please refer to Chapter 2 of the STC12 series microcontroller data sheet:

Reference address:Idle mode and sleep mode of STC12 series microcontrollers

Previous article:Some empirical understanding of microcontroller current
Next article:Multi-core processor architecture and debugging

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号