How does STM32 enter the interrupt function xxx_IRQHandler

Publisher:Serendipitous55Latest update time:2018-06-08 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

How does STM32 enter the interrupt function xxx_IRQHandler, such as: void USART1_IRQHandler(void) 
When I started to use STM32 some time ago, I encountered such a problem. When the interrupt settings are configured in the program, how does the program enter the interrupt function when it is running (of course, the interrupts mentioned here are all hardware interrupts), because when running a C program, my understanding is that you always have to have a "baton" or an "entrance" before it can enter the next function. Take 
uart1 configuration as an example, 
//Interrupt initialization 
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); 
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; 
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; 
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 
NVIC_Init(&NVIC_InitStructure);

/Serial port initialization 
USART_StructInit(&USART_InitStructure); //Serial port 1 uses default configuration 
USART_Init(USART1, &USART_InitStructure); //Initialize serial port 
USART_Cmd(USART1, ENABLE); //Enable serial port

USART_ITConfig(USART1, USART_IT_TXE, DISABLE); //Disable send buffer empty interrupt 
USART_ITConfig(USART1, USART_IT_TC , ENABLE); //Send complete interrupt 
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); //Receive interrupt 
USART_ITConfig(USART1, USART_IT_IDLE, ENABLE); //Receive idle interrupt


When an interrupt occurs, the program responds to the interrupt service function void USART1_IRQHandler(void)  in stm32f10x_it.c 
{

#if OS_CRITICAL_METHOD == 3                      
    OS_CPU_SR cpu_sr = 0;
#endif
OS_ENTER_CRITICAL(); 
OSIntEnter();
OS_EXIT_CRITICAL();

UartISR(U1ART);
OSIntExit();12345678910


So how does the program find it? In the startup file startup_stm32f10x_md.s, there is a piece of code that assembles 
DCD USART1_IRQHandler 
, where DCD is a data definition pseudo instruction, which is used to allocate a continuous word storage unit and initialize it with specified data. 
There are also some such as PUBWEAK USART1_IRQHandler, etc., the specific meaning is not very clear. 
The library defines #define USART1 ((USART_TypeDef *) USART1_BASE) 
and #define USART1_BASE (APB2PERIPH_BASE + 0x3800). 
My personal understanding is that when the control register interrupt enable of USART1 is configured, when an interrupt (exception) occurs, the exception is accepted by the Cortex-M3 core, and the corresponding exception Handler will be executed. And this response process is completed by hardware. Of course, in order to determine the entry address of the Handler, Cortex-M3 uses the "vector table lookup mechanism". The startup_stm32f10x_md.s startup file has assigned this address to USART1_IRQHandler. So after an exception occurs, the CPU enters the exception mode, and the program counter PC automatically points to the exception entry address, that is, USART1_IRQHandler, and then executes the application in the interrupt service function.


Keywords:STM32 Reference address:How does STM32 enter the interrupt function xxx_IRQHandler

Previous article:Solution to the problem that the STM32 timer cannot exit after entering an interrupt
Next article:Debugging serial port interrupts in STM32

Recommended ReadingLatest update time:2024-11-16 19:36

STM32 ADC sampling time, sampling period, sampling frequency calculation method
ADC conversion is the conversion of analog input signals into digital signals by the microcontroller. To read the digital signal, you must wait until the conversion is completed. The completion of a channel reading is called the sampling cycle. Generally speaking, the sampling cycle = conversion time + reading time.  
[Microcontroller]
Design of a portable carbon dioxide monitor based on STM32
    The detection methods of CO2 concentration can be roughly divided into chemical methods and physical methods. The detection methods of CO2 concentration include titration, thermal catalysis, gas sensing, and electrochemical methods. These methods are chemical methods, which generally have problems such as high pric
[Medical Electronics]
Design of a portable carbon dioxide monitor based on STM32
STM32 I2C module debugging summary
 I debugged the I2C module of STM32 some time ago, and I will make a summary today. I will not repeat the knowledge about I2C protocol here. There are many articles introducing I2C protocol on the Internet. There are currently two ways to implement I2C protocol. One is to use GPIO port to simulate I2C protocol, and th
[Microcontroller]
STM32 I2C module debugging summary
Simulated serial port based on STM32 series (non-blocking)
STM32 microcontrollers generally have at least 3 serial ports and at most 5 serial ports, but for my project, 5 hardware serial ports are not enough. As for the reason why it is not enough, well, it is because the project is customized later, and any serial port cannot be saved. There is no way, I can only think of
[Microcontroller]
Simulated serial port based on STM32 series (non-blocking)
STM32 matrix keyboard input through serial port three output
Configuring Matrix Keyboard Input //PA0~PA3 are push-pull output //PA4~PA7 are pull-up inputs //PA9- RXD PA10- TXD   void  KEY44_Init(void) { //PA0~PA3 are push-pull output   GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 |GPIO_P
[Microcontroller]
Error: Flash Download failed - " appears during stm32 debugging
That is, the Flash programming algorithm in MDK is not configured or is not configured correctly. After adding it,
[Microcontroller]
Error: Flash Download failed -
STM32 program transplantation_Internal flash boot times management
1. Test environment: STM32C8T6 2. Test interface: 3. The serial port uses serial port 1, baud rate 9600 MCU pins------------CH340 pins VCC--------------------VCC GND-------------------GND PA9--------------------RXD   PA10-------------------TXD 1. Function: 1. Use STM32 internal falsh to record the number of boot times
[Microcontroller]
STM32 program transplantation_Internal flash boot times management
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号