ここ参照します。
http://blog.ednchina.com/STM32/143803/message.aspx/* 0 bits for pre-emption priority 4 bits for subpriority */
#define NVIC_PriorityGroup_0 ((u32)0x700)
/* 1 bits for pre-emption priority 3 bits for subpriority */
#define NVIC_PriorityGroup_1 ((u32)0x600)
/* 2 bits for pre-emption priority 2 bits for subpriority */
#define NVIC_PriorityGroup_2 ((u32)0x500)
/* 3 bits for pre-emption priority 1 bits for subpriority */
#define NVIC_PriorityGroup_3 ((u32)0x400)
/* 4 bits for pre-emption priority 0 bits for subpriority */
#define NVIC_PriorityGroup_4 ((u32)0x300)
割り込みを発生する時、優先順位高いの関数が優先順位低いの関数を中断して先に実行する。
pre-emptionの数字が低いの方が優先順位が高い、例えば:0が1より優先が高い。
pre-emptionは同じの場合、subpriorityの数字を確認する、小さいの方が高い。
わたしのコードが下記を示す
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN_RX0_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable USART1 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_Init(&NVIC_InitStructure);
/* Enable the DMA1 Channel1 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel1_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
優先1、USART1
優先2、USB
優先3、DMA1
0 件のコメント:
コメントを投稿