Recently I read something shared by Tough Guy: Why is the main function called directly in the reset interrupt service routine? Are all programs executed in the reset interrupt?
First of all, Reset_Handler is an interrupt of the microcontroller. Secondly, the main function is indeed called by the Reset_Handler interrupt. Isn't that right? The main function is executed in the interrupt?
Seeing this question, have you ever thought about it? Was our previous understanding wrong?
To be honest, I have never thought about this problem. I think most people have not thought about this problem. So, by the way, I would like to share the content of this question.
Microcontroller operating modes
The microcontroller here mainly refers to the ARM Cortex-M core microcontroller.
To answer the opening question, we need to mention the operating modes of the microcontroller. Here we take the Cortex-M3 microcontroller as an example. Cortex-M3 supports two modes and two privilege levels.
Two modes:
Handler pattern
Thread mode
Two levels:
privilege level
user level
There is this paragraph in the Cortex-M3 manual:
Among them, I have circled the answers to the opening questions.
The official online documentation also mentions relevant instructions:
address:
https:// developer.arm.com/docum entation/dui0552/a/the-cortex-m3-processor/exception-model/exception-types
Example analysis
The answer is circled above. Maybe you are still confused. Here is a simple comparison and analysis based on the engineering code of Keil MDK + STM32.
1. Enter Reset_Handler to interrupt our online debugging, reset the state, enter Reset_Handler to reset the interrupt:
At this time, it is mentioned in the document: after reset, the processor enters the privileged Thread mode.
2. Enter the SysTick_Handler interrupt. When we enter a normal interrupt, for example, enter the SysTick_Handler clock tick interrupt here:
At this point, we have entered the privileged Handler mode.
Seeing this, I think you should understand.
Summarize
The key point of this question is:
The operation modes of reset interrupt (Reset_Handler) and ordinary interrupt (SysTick_Handler) are different.
Other IDEs, such as Keil, GCC and other compilation environments, have similar principles. This problem mainly lies in the kernel, which is determined by the kernel.
Maybe you have never cared about this problem. Of course, we rarely encounter corresponding problems.
This is not a problem. It doesn’t matter if you don’t understand it. What you saw today can be regarded as a knowledge point that further understands the Cortex-M microcontroller core.
Previous article:Things like MCU reset and program startup
Next article:Microcontroller custom protocol FIFO efficient data sending method
- 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)
- Learn ARM development (6)
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
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- Common usage of MSP430 watchdog and writing method of interrupt function
- Design issues of RC circuit between MOSFET drain and source
- 【Smart cup holder】05-Connect to Alibaba Cloud to synchronize time and data
- ATK-0.96' OLED module
- [Project source code] Linux view and delete processes
- Thanks for having you + the big prawns in the forum
- Design of real-time image test device based on LVDS technology
- Test丨You must first know your own isolation before you can measure the isolation level of others!
- [GD32L233C-START Review] 18. Hardware SPI driver (ST7735) 1.8-inch TFT LCD
- Difference between TMS320x281x and TMS320x2833x/TMS320x2823x