About the location and redirection of STM32 interrupt vector table

Publisher:独享留白1028Latest update time:2016-09-02 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
First we need to jump to the main function, which I won't go into detail about. So, after an interrupt occurs, how do we get to the interrupt entry address?

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:

41

The corresponding bin file, see if it is placed at the above address:

42

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

Keywords:STM32 Reference address:About the location and redirection of STM32 interrupt vector table

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

STM32 Study Notes 4: GPIO
GPIO—general purpose input output: is the abbreviation of general purpose input and output port. In simple terms, it is a software-controllable pin. The GPIO pins of the STM32 chip are connected to external devices to achieve external communication, control and data acquisition functions. GPIO functional block diagram
[Microcontroller]
STM32 Study Notes 4: GPIO
STM32 controls the rotation of the servo
Servo model: SG5010 servo Since servos generally operate at 5V or higher voltage, I was worried whether the STM32 output voltage is 3.3V and whether it can be driven. It turns out that it can. Use Time3 channel 2 as the PWM timer to output a 50HZ square wave with a pulse width between 0.5ms and 2.5ms. The prescaler is
[Microcontroller]
The difference between STM32 timer output comparison mode and PWM output mode
I spent several days trying to get a timer to output a square wave. It worked fine at first, but then it stopped working. I was so frustrated...  After a long period of oscilloscope observation and exploration, I found that the functions of the registers in the ordinary comparison output mode and the PWM mode are di
[Microcontroller]
The difference between STM32 timer output comparison mode and PWM output mode
STM32 Notes --- DMA (USART) Demonstration
 Here is a small example to demonstrate that the DMA module works in parallel with the system program.   It takes nearly 10 seconds to send a 10K data at a low baud rate through the serial port. At this time, according to the previous method, the CPU has to keep waiting for data to be sent, sending data; or sending
[Microcontroller]
STM32 study notes - using the general timer TIM2 for precise delay
1. General timer overview and performance 1.1 Overview On the stm32 chip used by the author, there is a total of 1 advanced timer TIM1 and 3 general timers TIM2, TIM3, and TIM4. Each general timer consists of a 16-bit auto-load counter driven by a programmable prescaler. It is suitable for a variety of occasions, in
[Microcontroller]
Establishing stm32 development environment under ubuntu: burning program openocd+openjtag
In the last blog, I wrote about how to build an STM32 development environment under Ubuntu. The program has been compiled to generate main.bin. The next step is to burn the file to STM32. To burn the program to ARM under Linux, openocd is mainly used. This software is open source and supports many chips, from ARM9 to
[Microcontroller]
STM32 ADC single conversion example
ADC initialization steps: 1. Initialize the channel IO used by ADC 2. Turn on the ADC clock and initialize the ADC structure 3. Call the ADC_Cmd function to enable ADC, so that the ADC register can be read and written 4. Calibrate the ADC (this step is not necessary. When calibrating the ADC, the ADC hardware will gen
[Microcontroller]
STM32 ADC single conversion example
8 working modes of GPIO in STM32!
In Cortex-M3, there are 8 types of GPIO configurations: (1) GPIO_Mode_AIN analog input  (2) GPIO_Mode_IN_FLOATING floating input (3) GPIO_Mode_IPD pull-down input  (4) GPIO_Mode_IPU pull-up input  (5) GPIO_Mode_Out_OD open-drain output (6) GPIO_Mode_Out_PP push-pull output (7) GPIO_Mode_AF_OD mul
[Microcontroller]
8 working modes of GPIO in STM32!
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号