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

[复制链接]
 楼主| 银河漫步 发表于 2025-5-9 15:42 | 显示全部楼层 |阅读模式
APM32F103的中断优先级组如何使用
极海APM32F103系列的MCU有中断优先级组的概念。通过查看代码可以看到极海官方定义了5个优先级。查看apm32f10x_misc.c/.h源文件,如下:
  1. /**
  2. * [url=home.php?mod=space&uid=247401]@brief[/url]   nvic priority group
  3. */
  4. typedef enum
  5. {
  6.     NVIC_PRIORITY_GROUP_0 = 0x700,  /*!< 0 bits for pre-emption priority,4 bits for subpriority */
  7.     NVIC_PRIORITY_GROUP_1 = 0x600,  /*!< 1 bits for pre-emption priority,3 bits for subpriority */
  8.     NVIC_PRIORITY_GROUP_2 = 0x500,  /*!< 2 bits for pre-emption priority,2 bits for subpriority */
  9.     NVIC_PRIORITY_GROUP_3 = 0x400,  /*!< 3 bits for pre-emption priority,1 bits for subpriority */
  10.     NVIC_PRIORITY_GROUP_4 = 0x300   /*!< 4 bits for pre-emption priority,0 bits for subpriority */
  11. } NVIC_PRIORITY_GROUP_T;
  1. /*!
  2. * [url=home.php?mod=space&uid=247401]@brief[/url]     Configures the priority grouping: pre-emption priority and subpriority.
  3. *
  4. * @param     priorityGroup : specifies the priority grouping bits length.
  5. *                            This parameter can be one of the following values:
  6. *                            [url=home.php?mod=space&uid=2817080]@ARG[/url] NVIC_PRIORITY_GROUP_0
  7. *                            @arg NVIC_PRIORITY_GROUP_1
  8. *                            @arg NVIC_PRIORITY_GROUP_2
  9. *                            @arg NVIC_PRIORITY_GROUP_3
  10. *                            @arg NVIC_PRIORITY_GROUP_4
  11. *
  12. * @retval    None
  13. */
  14. void NVIC_ConfigPriorityGroup(NVIC_PRIORITY_GROUP_T priorityGroup)
  15. {
  16.     SCB->AIRCR = AIRCR_VECTKEY_MASK | priorityGroup;
  17. }


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

jobszheng 发表于 2025-5-9 18:56 | 显示全部楼层
我倒是一般会使用NVIC_PRIORITY_GROUP_3
幻影书记 发表于 2025-5-9 18:58 | 显示全部楼层
一直使用的示例里面的 NVIC_PRIORITY_GROUP_0 。
寂静小夜曲 发表于 2025-5-12 17:58 | 显示全部楼层
印象中,官方建议使用4.
发光的梦 发表于 2025-5-13 18:17 | 显示全部楼层
没有配置过个参数。一直使用的是系统默认值
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

36

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部

1

主题

36

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部