From stm32f10x.s, we can see that a lot of interrupt response functions have been defined. This is the interrupt vector table. The label __Vectors indicates the entry address of the interrupt vector table, for example:
AREA RESET, DATA, READONLY; Define the read-only data segment, which is actually in the CODE area (assuming that STM32 is started from FLASH, the starting address of this interrupt vector table is 0x8000000)
EXPORT __Vectors
IMPORT OS_CPU_SysTickHandler
IMPORT OS_CPU_PendSVHandler
__Vectors DCD __initial_sp; Top of Stack
DCD Reset_Handler; Reset Handler
DCD NMI_Handler; NMI Handler
DCD HardFault_Handler; Hard Fault Handler
DCD MemManage_Handler; MPU Fault Handler
DCD BusFault_Handler; Bus Fault Handler
DCD UsageFault_Handler; Usage Fault The writing of the Handler
vector table is particular. It corresponds to the hardware one by one and cannot be written randomly. The CPU relies on it to find the entry address. The beginning of the bin file is their address. The arrangement can be seen in Section 10.1.2 of the reference manual RM0008.
Let's combine the characteristics of CORTEX-M3. After it is powered on, it determines the PC position according to the boot pin. For example, if the boot is set to flash startup, the PC jumps to 0x08000000 after startup. At this time, the CPU will first take 2 addresses, the first is the top address of the stack, and the second is the reset exception address, so there is the above writing method, so it jumps to reset_handler.
So what is the actual address of this reset_handler? What is the address of the following pile of Nmi_handler? How does an interrupt run to this address? Let's explain them one by one.
1. We can know these entry addresses by reverse. You can see it by checking the map file under the project. This address is closely related to the target->flash start address set in keil. In fact, we don't need to care too much. Let the compiler allocate it. The interrupt vector table puts their addresses.
2. Compared with ARM7/ARM9 cores, the Cortex-M3 core has a fixed interrupt vector table location and a variable start address.
3. After entering the C language, NVIC will be configured first. In NVIC_SetVectorTable(), the start address and offset of the interrupt vector table can be configured. It mainly tells the CPU whether the vector table is located in Flash or Ram, and what the offset is. For example, if it is set to be located in Flash, the offset is the address of the program burned in, which can be set in the Keil target. In this way, the CPU knows the entry address.
4. After an interrupt occurs, the CPU finds the interrupt vector table address, and then finds the interrupt address based on the offset (matching the number), so it jumps to the interrupt address.
Let's take a screenshot to illustrate the map file:
The corresponding bin file, see if it is placed at the above address:
Obviously, 200039c0 is the top address of the stack, and 08006F21 is the reset_handler address!
How to locate? Take 0x20000000 as an example
1. Keil sets the RAM start to 0x20000100. We put the interrupt vector table at 0x20000000~0x20000100, and the rest is for the program.
2. Set NVIC_SetVectorTable(NVIC_VectTab_FLASH,0);
3. When jumping to C, copy the interrupt vector table to 0x20000000
Previous article:About the porting of contiki system to STM32
Next article:CoAP Server solution based on STM32 platform
Recommended ReadingLatest update time:2024-11-16 12:42
- Popular Resources
- Popular amplifiers
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
- Can the 66AK2L06 SoC enable miniaturization of test and measurement equipment?
- Circuit diagram of leakage alarm automatic control socket
- How to detect mosquitoes using ultrasonic sensor circuit
- 2021 National College Student Electronics Competition Released
- Share the application manuals, library functions, routines and selection tables of the full range of MM32 MCU products of Lingdong Microelectronics
- 【Construction Monitoring and Security System】Work Submission Post
- Live FAQ|Typical applications in the era of the Internet of Things
- CCS import routine for TM4C123x
- EEWORLD University Hall----Signal Integrity and High-Speed Digital Circuit Design
- Competition Schedule [Updated]