搜索
bottom↓
回复: 6

MK60FX中断嵌套问题求救

[复制链接]

出0入0汤圆

发表于 2013-11-5 08:48:36 | 显示全部楼层 |阅读模式
想要实现定时中断和外部中断嵌套,就是在定时中断中有外部中断到来时,及时进入外部中断,外部中断结束之后返回定时中断,我用set_irq_priority设置了中断优先级,但是不能实现中断嵌套。各位大神帮小弟看看

阿莫论坛20周年了!感谢大家的支持与爱护!!

如果想吃一顿饺子,就得从冰箱里取出肉,剁馅儿,倒面粉、揉面、醒面,擀成皮儿,下锅……
一整个繁琐流程,就是为了出锅时那一嘴滚烫流油的热饺子。

如果这个过程,禁不住饿,零食下肚了,饺子出锅时也就不香了……《非诚勿扰3》

出0入0汤圆

发表于 2013-11-5 08:51:13 | 显示全部楼层
还有 配置 优先级分组,默认是 不使用 嵌套中断

出0入0汤圆

 楼主| 发表于 2013-11-5 08:55:55 | 显示全部楼层
fire 发表于 2013-11-5 08:51
还有 配置 优先级分组,默认是 不使用 嵌套中断

请教下火哥如何配置优先级分组

出0入0汤圆

发表于 2013-11-5 11:17:14 | 显示全部楼层
查看一下中断向量表是否指向正确的中断服务程序,我看周立功论坛里有一个类似的问题:
http://bbs.zlgmcu.com/dispbbs.asp?BoardID=41&ID=14075

出0入0汤圆

发表于 2013-11-5 11:21:11 | 显示全部楼层
w111liang222 发表于 2013-11-5 08:55
请教下火哥如何配置优先级分组

用 CMSIS 库 即可,我贴 一下 源代码:
  1.     /** \brief  Set Priority Grouping

  2.       This function sets the priority grouping field using the required unlock sequence.
  3.       The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field.
  4.       Only values from 0..7 are used.
  5.       In case of a conflict between priority grouping and available
  6.       priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.

  7.         \param [in]      PriorityGroup  Priority grouping field
  8.      */
  9.     static __INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
  10.     {
  11.         uint32_t reg_value;
  12.         uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07);               /* only values 0..7 are used          */

  13.         reg_value  =  SCB->AIRCR;                                                   /* read old register configuration    */
  14.         reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk);             /* clear bits to change               */
  15.         reg_value  =  (reg_value                                 |
  16.                        ((uint32_t)0x5FA << SCB_AIRCR_VECTKEY_Pos) |
  17.                        (PriorityGroupTmp << 8));                                     /* Insert write key and priorty group */
  18.         SCB->AIRCR =  reg_value;
  19.     }



  20.     /** \brief  Enable External Interrupt

  21.         This function enables a device specific interrupt in the NVIC interrupt controller.
  22.         The interrupt number cannot be a negative value.

  23.         \param [in]      IRQn  Number of the external interrupt to enable
  24.      */
  25.     static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
  26.     {
  27.         /*  NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F));  enable interrupt */
  28.         NVIC->ISER[(uint32_t)((int32_t)IRQn) >> 5] = (uint32_t)(1 << ((uint32_t)((int32_t)IRQn) & (uint32_t)0x1F)); /* enable interrupt */
  29.     }


  30.     /** \brief  Set Interrupt Priority

  31.         This function sets the priority for the specified interrupt. The interrupt
  32.         number can be positive to specify an external (device specific)
  33.         interrupt, or negative to specify an internal (core) interrupt.

  34.         Note: The priority cannot be set for every core interrupt.

  35.         \param [in]      IRQn  Number of the interrupt for set priority
  36.         \param [in]  priority  Priority to set
  37.      */
  38.     static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
  39.     {
  40.         if(IRQn < 0)
  41.         {
  42.             SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff);
  43.         } /* set Priority for Cortex-M  System Interrupts */
  44.         else
  45.         {
  46.             NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff);
  47.         }        /* set Priority for device specific Interrupts  */
  48.     }
复制代码

出0入0汤圆

发表于 2013-11-5 11:22:59 | 显示全部楼层
NVIC_SetPriorityGrouping  函数, PriorityGroup 范围为 0~ 4 :

PriorityGroup = 0表示 0bit 抢占优先级  ,4bit 亚优先级 (默认的,由于都是相同抢占优先级,所以不支持中断嵌套)
PriorityGroup = 1表示 1bit 抢占优先级  ,3bit 亚优先级 (2个抢占优先级)
如此类推……

出0入0汤圆

 楼主| 发表于 2013-11-5 12:43:35 | 显示全部楼层
fire 发表于 2013-11-5 11:22
NVIC_SetPriorityGrouping  函数, PriorityGroup 范围为 0~ 4 :

PriorityGroup = 0表示 0bit 抢占优先级 ...

那进行优先级分组之后,如何给各个中断号分配抢占优先级
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-3-28 17:10

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表