问题描述
我正在使用 msp432 Arm 控制器创建一个 RTOS 内核。我正在使用 PendSV 进行上下文切换。 问题是当 systick 处理程序设置了 PendSV 处理程序但它从未被调用时。我的 Systick 处理程序的优先级为 0,PendSV 的优先级为 15。我不确定出了什么问题,但我试图最小化程序,但这没有帮助。任何建议都会有所帮助,谢谢。
void SysTick_Handler(void) {
OS_tick();
__disable_interrupts(); // @suppress("Function cannot be resolved")
OS_sched();
__enable_interrupts(); // @suppress("Function cannot be resolved")
}
void OS_init(void *stkSto,uint32_t stkSize){
// set the penSV interrupt priority to the lowest level
NVIC_SetPriority( PendSV_IRQn,0xFF) ; // @suppress("Invalid arguments")
OSThread_start(&idleThread,&main_idleThread,stkSto,stkSize);
}
void OS_sched(void){
if(OS_readySet == 0U){ // idle condition
OS_currIdx = 0U; // set oscurridc to idle thread
}
else{
// if else we have threads to run need ot do in round robin
do{
++OS_currIdx;
if(OS_currIdx == OS_ThreadNum){
OS_currIdx = 1U;
}
} while((OS_readySet & (1U << (OS_currIdx - 1U))) == 0U);
}
OS_next = OS_thread[OS_currIdx];
if(OS_next != OS_curr){
// Pend a PendSV exception using by writing 1 to PENDSVSET at bit 28
*(uint32_t volatile *)0xE000ED04 = (0x1 << 28);
}
}
void PendSV_Handler(void)
{
PendSV_HandlerAsm();
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)