STM32 interrupt configuration self-study summary

Publisher:自由思考Latest update time:2017-11-29 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Simply record the interrupt configuration instructions of STM32!

----The first part is---interrupt vector table-----




--------This is just a simple reference----Different versions are slightly different--but they are basically the same----You can search for it in the startup file---startup_stm32f10x_hd.s.

----Part 2---Interrupt priority configuration

static void NVIC_Configuration(void)
{
  NVIC_InitTypeDef NVIC_InitStructure;

  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); //Grouping

  NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn; //Main place
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; //Preemption
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //Sub-priority
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
}
----Part 3---Interrupt port configuration

void EXTI_PA0_Config(void)
{
  GPIO_InitTypeDef GPIO_InitStructure; 
  EXTI_InitTypeDef EXTI_InitStructure;

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO,ENABLE);

  NVIC_Configuration();

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;       
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //Port pull-up
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource0); //PA0 is the external interrupt input
  EXTI_InitStructure.EXTI_Line = EXTI_Line0;  
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; //Interrupt mode---the other is event mode
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //The trigger mode is falling edge
  EXTI_InitStructure.EXTI_LineCmd = ENABLE; //Enable
  EXTI_Init(&EXTI_InitStructure); 
}

----Part 4---Interrupt Function

void EXTI0_IRQHandler(void)
{
  if(EXTI_GetITStatus(EXTI_Line0) != RESET) //Generate corresponding interrupt
  {
    .........................
    EXTI_ClearITPendingBit(EXTI_Line0); //Clear interrupt flag bit
  }  
}


Keywords:STM32 Reference address:STM32 interrupt configuration self-study summary

Previous article:STM32 DS18B20 code detailed study summary
Next article:STM32 GPIO simple operation function

Recommended ReadingLatest update time:2024-11-16 15:31

STM32 Flash as memory to store data
When it comes to STM32's FLASH, our first reaction is that it is used to install programs. In fact, the STM32's on-chip FLASH is not only used to install programs, but also to install chip configuration, chip ID, bootloader, etc. Of course, FLASH can also be used to store data.  I have collected some information an
[Microcontroller]
STM32 SYSTICK
void  SysTick_Config(void); //SysTick timer configuration  void  Delay_Ms(u32);//timing time configuration  void  void  SysTickHandler(void);//interrupt timing time processing function  static  vu32  TimingDelay;//interrupt processing function    //SysTick settings  void  SysTick_Config(void)  {         
[Microcontroller]
CAN bus debugging of STM32
This week, I debugged the CAN of STM32 and collected some information from the Internet. Thanks to the original author for his selfless contribution. Here are some key points: 1. CAN filter As for the filter, it is not very clear in the Chinese manual. STM32 has a total of 14 groups of filters to filter the receiv
[Microcontroller]
Use of STM32 independent watchdog
STM32 has two watchdogs: independent watchdog and window watchdog. This article mainly introduces the use of independent watchdog. Independent watchdog (IDWG): driven by an independent 40KHZ low-speed clock. Therefore, even if the main clock fails, the IDWG can still work normally. Windowed Watchdog (WWDG): Driven b
[Microcontroller]
STM32 SPI serial line and HC595 use
/*  Name: STM32 SPI serial line and HC595 use  illustrate: SPI: Serial Peripheral Interface is a high-speed full-duplex communication bus. It is widely used between ADC, LCD and other devices and MCU, where a high communication rate is required. For SPI, there are four main lines: CS, MOSI, MISO, and CLK. Among them
[Microcontroller]
STM32 uses HAL library to do DMA transmission and interrupt reception of serial port
The HAL library is too rigid HAL serial port interrupt reception The HAL library is too inflexible and has too many restrictions. If I have time, I will use a mixed operation method of registers and HAL library. For example,  when using serial port interrupt reception, after receiving data, the library has disabled th
[Microcontroller]
Comparison of STM32 and LPC series ARM resources
Due to the influence of Zhou Ligong's development board, the LPC series development board is generally considered one of the best models for engineers to get started. This time there happened to be an STM32 competition, so it was a good opportunity to compare the resources of the two (taking LPC213X as an example of th
[Microcontroller]
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号