管理员
  
- 积分
- 165475
- 金钱
- 165475
- 注册时间
- 2010-12-1
- 在线时间
- 2115 小时
|
发表于 2012-6-22 16:38:32
|
显示全部楼层
这个要看CM3权威指南.
有个SCB->SHPR的寄存器组,设置这个就可以设置SYSTICK的优先级.
在库函数里面的实现代码如下:
void NVIC_SystemHandlerPriorityConfig(u32 SystemHandler, u8 SystemHandlerPreemptionPriority,
u8 SystemHandlerSubPriority)
{
u32 tmp1 = 0x00, tmp2 = 0xFF, handlermask = 0x00;
u32 tmppriority = 0x00;
/* Check the parameters */
assert_param(IS_PRIORITY_SYSTEM_HANDLER(SystemHandler));
assert_param(IS_NVIC_PREEMPTION_PRIORITY(SystemHandlerPreemptionPriority));
assert_param(IS_NVIC_SUB_PRIORITY(SystemHandlerSubPriority));
tmppriority = (0x700 - (SCB->AIRCR & (u32)0x700))>> 0x08;
tmp1 = (0x4 - tmppriority);
tmp2 = tmp2 >> tmppriority;
tmppriority = (u32)SystemHandlerPreemptionPriority << tmp1;
tmppriority |= SystemHandlerSubPriority & tmp2;
tmppriority = tmppriority << 0x04;
tmp1 = SystemHandler & (u32)0xC0;
tmp1 = tmp1 >> 0x06;
tmp2 = (SystemHandler >> 0x08) & (u32)0x03;
tmppriority = tmppriority << (tmp2 * 0x08);
handlermask = (u32)0xFF << (tmp2 * 0x08);
SCB->SHPR[tmp1] &= ~handlermask;
SCB->SHPR[tmp1] |= tmppriority;
}
|
|