移植ucosII到STM32F103ZE(五) 作者: 时间:2016-11-25 来源:网络 收藏 PendSV 中断处理函数伪代码如下:OS_CPU_PendSVHandler(){if (PSP != NULL) {Save R4-R11 onto task stack;OSTCBCur->OSTCBStkPtr = SP;}OSTaskSwHook();OSPrioCur = OSPrioHighRdy;OSTCBCur = OSTCBHighRdy;PSP = OSTCBHighRdy->OSTCBStkPtr;RestoreR4-R11 from new task stack;Returnfrom exception;}OS_CPU_PendSVHandler;xPSR, PC, LR, R12, R0-R3 已自动保存 #0CPSIDI;任务切换期间需要关中断MRSR0, PSP;R0 = PSP;如果 PSP ==0,跳到OS_CPU_PendSVHandler_nosave 执行 #1CBZR0, OS_CPU_PendSVHandler_nosave;保存 R4-R11 到任务堆栈SUBSR0, R0, #0x20;R0 -= 0x20