51 MCU software program reset

Publisher:温柔阳光Latest update time:2016-06-08 Source: eefocus 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
    ; Pop up 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 with C51



Method 1:   



void(*SoftReset)();



SoftReset=0;



SoftReset();



Explanation: Use 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 endasmMethod



3: In the C51 programming process, use a non-existent function to cause a reset.



The following program compiles normally, but resets when it is executed to 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 the watchdog reset.

Reference address:51 MCU software program reset

Previous article:51 MCU serial port program, string/hexadecimal sending and receiving
Next article:CY in 51 MCU software I2C driver

Recommended ReadingLatest update time:2024-11-16 21:51

[51 MCU Quick Start Guide] 2.4: 74HC595, LED dot matrix screen and its SPI control
Puzhong 51-Single-core-A2 STC89C52 Keil uVision V5.29.0.0 PK51 Prof. Developers Kit Version:9.60.0.0 Hard Knowledge Selected from "Popular 51 Single-Chip Microcomputer Development Strategy_V1.2" IO port expansion method - serial to parallel        The chip used is 74HC595. The development board has one 74HC595 chi
[Microcontroller]
[51 MCU Quick Start Guide] 2.4: 74HC595, LED dot matrix screen and its SPI control
Single chip microcomputer (AT89C51) timer/counter experiment case
case analysis Here are three types that are often encountered: It is known that the 8051 microcontroller's fosc=12MHz is timed by T1. Try to program the P1.0 pin to output a square wave with a period of 2ms. Given that the 8051 microcontroller has a fosc of 12MHz and uses T1 for timing, try programming the P1.0 pi
[Microcontroller]
Single chip microcomputer (AT89C51) timer/counter experiment case
Function and structure of the timer/counter of 80C51 single chip microcomputer
The 80C51 microcontroller has two 16-bit programmable timer / counters . Programmable means that its functions (such as working mode, timing time, range, start mode, etc.) can be determined and changed by instructions. In addition to two 16-bit counters, the timer/counter also has two special function registers (c
[Microcontroller]
Function and structure of the timer/counter of 80C51 single chip microcomputer
51 MCU key level reading program
When reading the button level, we usually use a delay function or a loop delay to reduce the jitter time and read the correct button level. Example: #include "reg52.h" sbit SysKey P0^0 sbit LED P0^1 #define SET 1 #define RESET 0 void Delay1ms(unsigned int ms) { unsigned char a,b,c; while(ms--) { for(c=17;c 0;c--) fo
[Microcontroller]
51 MCU key level reading program
Features and Applications of Cygnal 51 Single Chip Microcomputer
1 Introduction The Cygnal C8051F series is a fully integrated mixed-signal system-on-chip microcontroller. With the continuous development of semiconductor production technology, the integration of the system-on-chip is getting higher and higher, and the reliability requirements of embedded control technology a
[Microcontroller]
Features and Applications of Cygnal 51 Single Chip Microcomputer
Design of digital capacitance meter based on AT89C2051 single chip microcomputer
Design Tasks Design and make a digital capacitance meter. The functions and requirements of the system are as follows: (1) The designed capacitance meter can measure capacitance less than 2μF. (2) The designed capacitance meter uses a 3.5-digit display with a maximum display value of 1 999.
[Microcontroller]
Traffic light design with time display based on 51 microcontroller
Function: Traffic light design with time display, 30 seconds north-south green light, east-west red light; 3 flashes of yellow light; switch to 30 seconds east-west green light, north-south red light; The specific timing time can be modified according to the program, with source program and simulation diagram. Simul
[Microcontroller]
51 MCU timer and counter explanation
In real life, such as product counting, speed measurement, time control and many other occasions, the functions of timers and counters are often needed. The 8051 microcontroller has two built-in timers and counters, which can be used to achieve timing and counting functions. Let's learn about the timers and counters i
[Microcontroller]
51 MCU timer and counter explanation
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号