如何解决尾链PendSV
我正在使用 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 举报,一经查实,本站将立刻删除。