SMOD: this bit is related to serial communication.

SMOD=0; When serial port mode 1, 2 and 3, the baud rate is normal.

SMOD=1; When serial port mode 1, 2 and 3, the baud rate is doubled.

GF1, gf0: two general working flag bits, which users can use freely.

PD: power down mode setting positioning.

PD = 0 MCU is in normal working state.

When PD = 1 single chip microcomputer enters the power down mode, it can be awakened by external interrupt or hardware reset mode. After entering the power down mode, the external crystal oscillator stops vibrating, CPU, timer and serial port stop working, and only external interrupt works.

IDL: idle mode setting positioning.

IDL = 0 MCU is in normal working state.

IDL = 1 single chip microcomputer enters idle mode, and the rest continue to work except that the CPU does not work. In idle mode, it can be awakened by any interrupt or hardware reset.

Power down mode and interrupt trigger wake-up test of AT89S52 single chip microcomputer

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; // Total open interrupt allowed

EX0=1; // External interrupt 1

IT0=1; // The falling edge of the external interrupt is triggered

}

/*************************************

Function name: keytest

Function: keyboard program, press the key to enter the 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 function: main function

**************************************/

void main()

{unsigned char aa = 0xfe;

init();

while(1)

{/ / implement water lamp

P0=aa;

aa= _ crol_ (aa,1);

delay();

keytest(); // Keyboard scan

}

}

/*************************************

Function name: INT0

Function function: interrupt service program

**************************************/

void Int0() interrupt 0 using 1

{

P0=0x00; // All lights on

delay();

delay();

delay();

}

Experimental results: after the MCU is powered on, the running water lamp can be seen to rotate; When the key key is pressed, the running water lamp stops and only one lamp is on; When the key connected to port p3.2 is pressed, all 8 lights are on, and then the water lamp flows to the original position. Moreover, after power failure, the external interrupt is triggered by the key to wake up the MCU. The effect is good and easy to trigger.

Conclusion: after the AT89S52 single chip microcomputer wakes up from the power down mode triggered by external interrupt, it first executes the external interrupt service program, and then returns to the interrupt point of the main program to continue to execute.

Leave a Reply

Your email address will not be published. Required fields are marked *