stm32 (two) stm32 interrupt priority setting

Publisher:脑力舞者Latest update time:2018-05-30 Source: eefocusKeywords:stm32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

stm32 priority
    1. Priority level:
      STM32 users can assign 16 levels of priority, that is, the upper four bits of the priority register NVIC->IP[x] are used to represent the priority of each interrupt.
   
    2. Priority group:
      In STM32, the priority of an interrupt is divided into: preemption priority and sub-priority.
      When making a priority judgment, the preemption priority is compared first and then the sub-priority is compared.
      In the firmware library, variables are used to represent the preemption priority and sub-priority respectively:
      NVIC_InitTypeDef.NVIC_IRQChannelPreemptionPriority; (preemption priority)
      NVIC_InitTypeDef.NVIC_IRQChannelSubPriority; (sub-priority)
      
      The priority group is the boundary between the preemption priority and the sub-priority:
      for example, if the priority group is set to 0x05, it means that the priority of each interrupt starts from the 5th bit as the boundary, and the upper two bits [6:7] are the preemption priority
      . The second bit is [5:4], which represents the sub-priority.
      
      Example:
      //Call the priority group setting function and set the priority to 0x05.
      .....
      NVIC_SetPriorityGrouping(5);
      .....
      //Here, it is explained that the 7th and 6th bits of a priority register (NVIC->IP[x]) represent the preemption priority. 5 and 4 represent the priority.   
      ......
      NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
      NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
      NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
      NVIC_Init(&NVIC_InitStructure);   
      .......
      //Here is the priority setting: From the above settings, we can know that the preemption priority and sub-priority range are both 3~0;
      //Then the priority of an interrupt is set

Keywords:stm32 Reference address:stm32 (two) stm32 interrupt priority setting

Previous article:STM32F4 sets NVIC interrupt priority grouping
Next article:Understanding interrupt priorities in STM32

Recommended ReadingLatest update time:2024-11-16 17:33

Learning STM32 general timer
Steps to generate interrupts using the STM32 general-purpose timer: 1) TIM3 clock enable 2) Set the values ​​of TIM3_ARR and TIM3_PSC Through these two registers, we set the auto-reload value and the frequency division factor. These two parameters plus the clock frequency determine the overflow time of the timer.
[Microcontroller]
Understanding of STM32 registers
Let's take the STM32F4 series as an example. It has 7 control buses and 8 controlled buses (S0-7). The crossed dots indicate that the two buses can communicate with each other. M0, M2, and M6 represent three different startup modes of STM32: FLASH startup (including system memory), internal SRAM startup, and external
[Microcontroller]
STM32 push-pull output and open-drain output
The IO port circuit of stm32 is shown in the figure above: The so-called push-pull output: when the output is high level, the P-MOS tube is turned on; when the output is low level, the N-MOS tube is turned on. The two tubes are turned on in turn, one is responsible for sinking current and the other is responsible fo
[Microcontroller]
STM32 push-pull output and open-drain output
STM32->DMA
Direct Memory Access (DMA):     It allows the hardware subsystem (peripheral) inside the CPU to read and write the system memory independently and directly. It allows hardware devices of different speeds to transfer data without relying on the CPU. The microcontroller uses DMA to provide high-speed data transmission
[Microcontroller]
STM32 programming ds18b20 single bus temperature sensor operation
1. Main program: #include "sys.h" #include "led.h" #include "delay.h" #include "usart.h" #include "lcd.h" #include "ds18b20.h" /* Program function: Use STM32 to implement DS18B20 single bus temperature sensor operation             LCD to display the current temperature;             and print out the temperatu
[Microcontroller]
STM32 PCB touch button (RC detection method)
I accidentally found the touch button program I used to fool my boss when I just graduated from college, and suddenly I felt that I have more gray hair. It is not easy to make hardware, it is not easy to make software, and it is even more difficult to make hardware and software. . . . Looking back, I don't have a deep
[Microcontroller]
Description of Cortex-M3 registers used in STM32
Three groups of registers defined by Cortex-M3 are used in STM32. The description of these three groups of registers is not in the technical manual of STM32. You need to refer to the Cortex-M3 Technical Reference Manual (r2p0) released by ARM.   Three structures are defined in the STM32 firmware library to correspon
[Microcontroller]
STM32 USB design microcontroller program
First, let's take a look at the working process of USB. When a USB device is connected to the host, the host begins to enumerate the USB device and sends a command to the USB device to obtain the relevant description information of the USB device, including device description (device descriptor), configuration
[Industrial Control]
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号