我正在使用 MSP432 Arm 控制器创建一个 RTOS 内核。我正在使用 PendSV 进行上下文切换。问题是当 systick 处理程序设置 PendSV 处理程序但它从未被调用时。我有优先级 0 的 Systick 处理程序和优先级 15 的 PendSV。我不确定出了什么问题,但我试图最小化程序,但这没有帮助。任何建议都会有所帮助,谢谢。
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();
}