ISP_CONTR: ISP/IAP control register
D7 |
D6 |
D5 |
D4 |
D3 |
D2 |
D1 |
D0 |
Reset value |
ISPEN |
SWBS |
SWRST |
- |
- |
WT2 |
WT1 |
WT0 |
000x,0000 |
-
SWBS: When set to 0, the software will start from the user application area after reset; when set to 1, the software will start from the ISP program area after reset. This can only be achieved by working directly with SWRST.
-
SWRST: When set to 0, no software reset is performed; when set to 1, a software system reset is generated and the hardware is automatically cleared.
This reset resets the entire system. All special function registers will be reset to their initial values and the I/O ports will also be initialized.
[Example] Use a key interrupt to reset the MCU software. After the reset, the LED light flashes for a while, and then the MCU maintains the current state and idles. If you want to continue flashing the LED, you need to reset the MCU.
Software reset code:
1 #include "stc.h"
2
3 #define LED_PORT P2 //Define LED control port as P2
4
5/************************************************
6 *Function name: Delay
7 * Input: None
8 *Output: None
9 *Description: Delay for a period of time
10************************************************/
11 void Delay(void)
12 {
13 unsigned char i,j;
14
15 for(i=0;i<130;i++)
16 for(j=0;j<255;j++);
17 }
18 /************************************************
19 *Function name:SoftReset
20 * Input: None
21 *Output: None
22 * Description: Software reset MCU
twenty three ********************************************/
24 void SoftReset(void)
25 {
26 ISP_CONTR=0x20;
27 }
28 /************************************************
29 *Function name:EXTInit
30 *Input: None
31 *Output: None
32 * Description: External interrupt initialization
33************************************************/
34 void EXTInit(void)
35 {
36 EX1=1; //Enable external interrupt 1
37 IT1=0; //Low level trigger
38 EA=1; //Enable all interrupts
39 }
40 /************************************************
41 *Function name: main
42 * Input: None
43 *Output: None
44 *Description: Function
45************************************************/
46 void main(void)
47 {
48 unsigned char i;
49
50 EXTInit(); //External interrupt initialization
51
52 for(i=0;i<20;i++) //Loop flashing LED light
53 {
54 LED_PORT=~LED_PORT;
55 Delay();
56 }
57
58 while(1)
59 {
60; //No operation
61 }
62 }
63 /************************************************
64 *Function name: EXT1IRQ
65 *Input: None
66 *Output: None
67 * Description: External interrupt 1 interrupt service function reset operation
68 ********************************************/
69 void EXT1IRQ(void)interrupt 2
70 {
71 SoftReset();
72 }
73
Code Analysis:
SoftReset is a reset operation function, which assigns the value of 0x20 to the ISP/IAP control register ISP_CONTR, that is, sets "SWRST" in ISP_CONTR to 1 to perform a software reset. It should be noted that the software reset here is a real reset, which has the same effect as a hardware reset.
In the main function, after initializing the external interrupt, the LED light flashes for a while, and then enters the while(1) infinite loop to perform no operations.
The software reset operation is placed in the external interrupt 1 interrupt service function. As long as the external interrupt 1 is triggered, the microcontroller will be reset.
Previous article:Simulate software reset
Next article:8051 MCU - interrupt wakeup
Recommended ReadingLatest update time:2024-11-16 09:47
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- UWB ultra-wideband positioning principle and application
- Understanding of several layers in drawing PCB
- How to use logic analyzer to debug SPI anomalies
- TI C6000 CodecEngine integrated algorithm core calling principle
- Commonly used techniques in PCB design
- [Silicon Labs Development Kit Review] Using TensorFlow to Prototype Gesture Recognition Project
- When IAR STM8 uses registers as uart, an error occurs when writing the receive interrupt. Please solve it
- EEWORLD University Hall----Live Replay: ADI Reference Voltage Source Product Technology and Application Selection
- Revolutionizing radar design with electronically reconfigurable GaN power amplifiers
- About the debugging of ML75308 optical rainfall chip???