smartfusion2 CORTEX-M3 NVIC 中断优先级
SmartFusion 2 Microcontroller Subsystem User Guide
根据 生成的头文件 m2sxxx.h 文件
#define __NVIC_PRIO_BITS 4 // 这里应该可以改成 7 , 但是 4位也够用了,因此没有更改
分组 设置成 B011, 则有 16个 抢占优先级, 取值范围 0-15;
因此 调用接口,
// 优先级 0-15
NVIC_SetPriorityGrouping( 0x03 );
// 例子 设置 串口0 优先级,取值范围 0-15;
NVIC_SetPriority( UART0_IRQn, 7 );
但是手册上,每个中断有 8bit 的优先级, 因为分组,最多有 128个抢占, 因此取值范围 0-127;
2.5.3.6. Interrupt Priority Grouping (Ask a Question)
To increase priority control in systems with interrupts, the NVIC supports priority grouping. This
divides each interrupt priority register entry into two fields:
• An upper field that defines the group priority
• A lower field that defines a subpriority within the group.
Only the group priority determines preemption of interrupt exceptions. When the processor is
executing an interrupt exception handler, another interrupt with the same group priority as the
interrupt being handled does not preempt the handler,
If multiple pending interrupts have the same group priority, the subpriority field determines the
order in which they are processed. If multiple pending interrupts have the same group priority and
subpriority, the interrupt with the lowest IRQ number is processed first.
For information about splitting the interrupt priority fields into group priority and subpriority, see
Application Interrupt and Reset Control Register.
2.5.3.6. 中断优先级分组(问题咨询)
为增强带中断系统中的优先级控制,NVIC支持优先级分组机制。该机制将每个中断优先级寄存器条目划分为两个字段:
• 高位字段定义组优先级
• 低位字段定义组内的子优先级
仅组优先级决定中断异常的抢占行为。当处理器正在执行某个中断异常处理程序时,具有相同组优先级的其他中断不会抢占当前处理程序。
若多个挂起中断具有相同组优先级,则子优先级字段决定其处理顺序。若多个挂起中断的组优先级和子优先级均相同,则IRQ编号最小的中断优先被处理。
优先级分组:因此 这里设置 优先级 分组 B011, 即可;


优先级:每个中断有8bit , 因此抢占优先级取值范围 0-255;

浙公网安备 33010602011771号