zoukankan      html  css  js  c++  java
  • [stm32]中断优先级设置

    pic

    1. 设置优先级组NVIC_PriorityGroupConfig
    2. 设置中断源的抢占优先级(pre-emption priority)响应优先级(sub-priority),然后使能
    3. 初始化NVIC_Init(&NVIC_InitStructure)
    void NVIC_Config(void)
    {
       NVIC_InitTypeDef NVIC_InitStructure;
       /* Configure the NVIC Preemption Priority Bits */
       NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
       /* Enable the USARTy Interrupt */
       NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
       NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
       NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
       NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
       NVIC_Init(&NVIC_InitStructure);
       //
       NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel4_IRQn;
       NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
       NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
       NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
       NVIC_Init(&NVIC_InitStructure);
    }
    

    NOTE

    1. NVIC_PriorityGroupConfig可设置多次,但以最后一次为准

    2. 设定的中断源优先级不能超过优先级组设置的范围,否则结果不可知

    3. 抢占式优先级别相同的中断源之间没有嵌套关系

    4. 当两个中断源的抢占式优先级相同时,这两个中断将没有嵌套关系

    5. 抢占式优先级或响应优先级相同时,根据他们在中断表中的排位顺序决定先处理哪一个

    Good Good Study! Day Day Up!

  • 相关阅读:
    数字配对(bzoj 4514)
    任务查询系统(bzoj 3932)
    楼房重建(bzoj 2957)
    Hotel(poj 3667)
    Can you answer these queries(spoj 1043)
    亚瑟王(bzoj 4008)
    潘多拉的盒子(bzoj 1194)
    Circling Round Treasures(codeforces 375c)
    莫队算法---基础知识介绍(转载)
    HDU 1141---Brackets Sequence(区间DP)
  • 原文地址:https://www.cnblogs.com/kdurant/p/4186326.html
Copyright © 2011-2022 走看看