这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » 国产MCU » APM32F103的中断优先级组如何使用

共1条 1/1 1 跳转至

APM32F103的中断优先级组如何使用

院士
2025-05-17 16:38:27     打赏

极海APM32F103系列的MCU有中断优先级组的概念。通过查看代码可以看到极海官方定义了5个优先级。查看apm32f10x_misc.c/.h源文件,如下:

/**
 * @brief   nvic priority group
 */
typedef enum
{
    NVIC_PRIORITY_GROUP_0 = 0x700,  /*!< 0 bits for pre-emption priority,4 bits for subpriority */
    NVIC_PRIORITY_GROUP_1 = 0x600,  /*!< 1 bits for pre-emption priority,3 bits for subpriority */
    NVIC_PRIORITY_GROUP_2 = 0x500,  /*!< 2 bits for pre-emption priority,2 bits for subpriority */
    NVIC_PRIORITY_GROUP_3 = 0x400,  /*!< 3 bits for pre-emption priority,1 bits for subpriority */
    NVIC_PRIORITY_GROUP_4 = 0x300   /*!< 4 bits for pre-emption priority,0 bits for subpriority */
} NVIC_PRIORITY_GROUP_T;


/*!
 * @brief     Configures the priority grouping: pre-emption priority and subpriority.
 *
 * @param     priorityGroup : specifies the priority grouping bits length.
 *                            This parameter can be one of the following values:
 *                            @arg NVIC_PRIORITY_GROUP_0
 *                            @arg NVIC_PRIORITY_GROUP_1
 *                            @arg NVIC_PRIORITY_GROUP_2
 *                            @arg NVIC_PRIORITY_GROUP_3
 *                            @arg NVIC_PRIORITY_GROUP_4
 *
 * @retval    None
 */
void NVIC_ConfigPriorityGroup(NVIC_PRIORITY_GROUP_T priorityGroup)
{
    SCB->AIRCR = AIRCR_VECTKEY_MASK | priorityGroup;
}

我看极海官方示例里面,有用优先级2的,也有用优先级4的!所以问题来了,大家在项目中都使用哪个优先级组?




关键词: APM32F103     中断     优先级    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]