51 MCU software (program) reset

Publisher:馥睿堂Latest update time:2013-06-06 Source: 21ic Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

51 MCU software reset assembly code

POP ACC ; pop return address

POP ACC

; Eject PC

MOV SP,#30H; After reset, SP is 07H, which will reset the stack

MOV PSW,#00H ; Clear register

CLR A ; push 0 as new

PUSH ACC; return address to stack

PUSH ACC

; Reset PC=0 and push it into the stack

RETI; execute return of interrupt

;The program starts running from 0000H again, but the value in the register is uncertain!

Implementing Software Reset Using C51

Method 1:

void(*SoftReset)();

SoftReset=0;

SoftReset();

Explanation: Use a function pointer to set the entry address of the function pointed to by the function pointer to 0.

Method 2: Embedded Assembly

#pragma asm

LJMP 0FFF0h; //ljmp 0000h

#pragma endasm

Method 3: During C51 programming, use a non-existent function to cause a reset.

The following program compiles fine, but resets when it reaches reset(). The assembly code is

LCALL C:0000.

extern void rest(void); //Does not actually exist.

void main()

{

rest(); //Reset

}

Method 4: If a watchdog is used, use a watchdog reset.

Reference address:51 MCU software (program) reset

Previous article:Summary of 51 MCU Timer
Next article:51 MCU register function list

Latest Microcontroller Articles
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号