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.
Previous article:Summary of 51 MCU Timer
Next article:51 MCU register function list
- Popular Resources
- Popular amplifiers
- Learn ARM development(15)
- 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)
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
- Learn ARM development(15)
- 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
- A four-way digital buzzer using Quartus II simulation and Verilog HDL programming
- Design of CCD camera dimming photoelectric control system based on MSP430 microcontroller
- Verification Method Overview
- 【ST NUCLEO-H743ZI Review】+ USB OTG+FATFS
- MSP432 learning notes: GPIO usage and configuration
- Mir MYC-YT507 Development Board Review: Development Environment Part 2: Python 2048 Game
- Double-T network band-stop filter and its variants
- New version of esptool
- Question about "Gain-Bandwidth Product GBW of Differential Amplifier Circuit"
- 006