SMOD: This bit is related to serial port communication.
SMOD=0; When serial port mode is 1, 2, 3, the baud rate is normal.
SMOD=1; When serial port mode is 1, 2, or 3, the baud rate is doubled.
GF1, GF0: Two general working flags, users can use them freely.
PD: Power-down mode setting bit.
PD=0 The microcontroller is in normal working state.
PD=1 The microcontroller enters the power down mode and can be awakened by an external interrupt or hardware reset mode. After entering the power down mode, the external crystal oscillator stops oscillating, the CPU, timer, and serial port all stop working, and only the external interrupt works.
IDL: Idle mode setting bit.
IDL=0 The microcontroller is in normal working state.
IDL=1 The MCU enters the idle mode. Except for the CPU, all other parts continue to work. In the idle mode, it can be awakened by any interrupt or hardware reset.
Test circuit diagram
The test procedure is as follows:
#include
#include
sbit key = P3^3; //Key to enter power-down mode
/****************************************
Function name: delay
Function: Delay for a period of time
***************************************/
void delay()
{
unsigned int i;
for(i=0;i<30000;i++);
}
/****************************************
Function name: delay20ms
Function: Delay 20ms
***************************************/
void delay20ms(void)
{
unsigned char i,j;
for(i=0;i<100;i++)
for(j=0;j<60;j++);
}
/****************************************
Function name: init
Function: Initialization program
***************************************/
void init()
{
EA=1; //Always enable interrupts
EX0=1; //Open external interrupt 1
IT0=1; //Falling edge trigger of external interrupt
}
/****************************************
Function name: keytest
Function: Keyboard program, press the key to enter power-down mode
***************************************/
void keytest()
{
if(key==0)
{
delay20ms();
if(key==0)
{
PCON=PCON|0x02; //Enter power-down mode
}
while(!key);
}
}
/****************************************
Function name: main
Function: Main function
***************************************/
void main()
{unsigned char aa = 0xfe;
init();
while(1)
{//Realize the running light
P0=aa;
aa= _crol_(aa,1);
delay();
keytest(); //Keyboard scan
}
}
/****************************************
Function name: Int0
Function: interrupt service routine
***************************************/
void Int0() interrupt 0 using 1
{
P0=0x00; //All lights are on
delay();
delay();
delay();
}
Experimental results: After the microcontroller is powered on, you can see the running lights rotating; when the key is pressed, the running lights stop and only one light is on; when the key connected to the P3.2 port is pressed, all 8 lights are on, and then the running lights continue to flow in the original position. Moreover, after power failure, the microcontroller is awakened by triggering an external interrupt through the key, the effect is good and it is easy to trigger.
Conclusion: After the AT89S52 microcontroller is awakened from power-down mode by an external interrupt, the external interrupt service program is executed first, and then it returns to the main program interrupt point to continue execution.
Previous article:Keil's C language compiler
Next article:51 MCU peripherals
Recommended ReadingLatest update time:2024-11-15 14:59
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Working principle and structure analysis of variable frequency series resonance
- EEWORLD University ---- Linux driver strategy and framework
- Phase shifter classification and working principle (Part 1)
- [TI recommended course] #Live replay: Application of TI millimeter wave sensors in smart home#
- EEWORLD University ---- Live playback: The most important component of the analog world - Signal chain and power supply: Amplifier special
- Help, how to calculate the voltage gain of an amplifier circuit?
- Xilinx XPE Power Estimation Software Setup Advisory
- Electronic password lock based on single chip microcomputer
- Anlu SparkRoad FPGA development board interface definition
- Analysis and Design of TL431 Feedback Loop