2个回答
展开全部
可以参照STM32提供的库函数,中断优先级有抢占优先级和响应优先级之分,可以在NVIC寄存器里进行响应配置,优先级数字越小代表的优先级越高。STM32提供的库函数有如下的操作,
NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn; //中断线1全局中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; //抢占优先级为2
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //响应优先级为0
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //允许EXTI0_IRQn中断
NVIC_Init(&NVIC_InitStructure);
你可以下载STM32固件库使用手册进行学习
NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn; //中断线1全局中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; //抢占优先级为2
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //响应优先级为0
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //允许EXTI0_IRQn中断
NVIC_Init(&NVIC_InitStructure);
你可以下载STM32固件库使用手册进行学习
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用库函数比较方便啦
/* Enable CAN1 SCE interrupt IRQ channel */
NVIC_InitStructure.NVIC_IRQChannel = CAN1_SCE_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable CAN1 SCE interrupt IRQ channel */
NVIC_InitStructure.NVIC_IRQChannel = CAN1_SCE_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询