|
1.uCOSIII的版本是V3.04.04,在IAR 下按照手册教程修改了OSTaskStkInit 和 OS_CPU_PendSVHandler两个函数
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CPU_STK *OSTaskStkInit (OS_TASK_PTR p_task,
void *p_arg,
CPU_STK *p_stk_base,
CPU_STK *p_stk_limit,
CPU_STK_SIZE stk_size,
OS_OPT opt)
{
CPU_STK *p_stk;
(void)opt; /* Prevent compiler warning */
p_stk = &p_stk_base[stk_size]; /* Load stack pointer */
/* Align the stack to 8-bytes. */
p_stk = (CPU_STK *)((CPU_STK)(p_stk) & 0xFFFFFFF8);
/* Registers stacked as if auto-saved on exception */
*--p_stk = (CPU_STK)0x01000000u; /* xPSR */
*--p_stk = (CPU_STK)p_task; /* Entry Point */
*--p_stk = (CPU_STK)OS_TaskReturn; /* R14 (LR) */
*--p_stk = (CPU_STK)0x12121212u; /* R12 */
*--p_stk = (CPU_STK)0x03030303u; /* R3 */
*--p_stk = (CPU_STK)0x02020202u; /* R2 */
*--p_stk = (CPU_STK)p_stk_limit; /* R1 */
*--p_stk = (CPU_STK)p_arg; /* R0 : argument */
/* Remaining registers saved on process stack */
*--p_stk = (CPU_STK)0x11111111u; /* R11 */
*--p_stk = (CPU_STK)0x10101010u; /* R10 */
*--p_stk = (CPU_STK)0x09090909u; /* R9 */
*--p_stk = (CPU_STK)0x08080808u; /* R8 */
*--p_stk = (CPU_STK)0x07070707u; /* R7 */
*--p_stk = (CPU_STK)0x06060606u; /* R6 */
*--p_stk = (CPU_STK)0x05050505u; /* R5 */
*--p_stk = (CPU_STK)0x04040404u; /* R4 */
#if (OS_CPU_ARM_FP_EN == DEF_ENABLED)
*--p_stk = (CPU_STK)0xFFFFFFFDUL;
#endif
return (p_stk);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
OS_CPU_PendSVHandler
CPSID I ; Prevent interruption during context switch
MRS R0, PSP ; PSP is process stack pointer
CBZ R0, OS_CPU_PendSVHandler_nosave ; Skip register save the first time
#ifdef __ARMVFP__ ; if IDE enable FPU uint ,will define __ARMVFP__
TST LR, #0x10
IT EQ
VSTMDBEQ R0!, {S16-S31}
MOV R3, LR
STMDB R0!,{R3-R11}
#else
STMDB R0!,{R4-R11}
#endif
LDR R1, =OSTCBCurPtr ; OSTCBCurPtr->OSTCBStkPtr = SP;
LDR R1, [R1]
STR R0, [R1] ; R0 is SP of process being switched out
; At this point, entire context of process has been saved
OS_CPU_PendSVHandler_nosave
PUSH {R14} ; Save LR exc_return value
LDR R0, =OSTaskSwHook ; OSTaskSwHook();
BLX R0
POP {R14}
LDR R0, =OSPrioCur ; OSPrioCur = OSPrioHighRdy;
LDR R1, =OSPrioHighRdy
LDRB R2, [R1]
STRB R2, [R0]
LDR R0, =OSTCBCurPtr ; OSTCBCurPtr = OSTCBHighRdyPtr;
LDR R1, =OSTCBHighRdyPtr
LDR R2, [R1]
STR R2, [R0]
LDR R0, [R2] ; R0 is new process SP; SP = OSTCBHighRdyPtr->StkPtr;
#ifdef __ARMVFP__
LDMIA R0!,{R3-R11}
MOV LR, R3
TST LR, #0x10
IT EQ
VLDMIAEQ R0!, {S16-S31}
#else
LDMIA R0!,{R4-R11}
#endif
MSR PSP, R0 ; Load PSP with new process SP
CPSIE I
BX LR ; Exception return will restore remaining context
END
并将这里注销了
#if (OS_CPU_ARM_FP_EN == DEF_ENABLED)
if ((OSTCBCurPtr->Opt & OS_OPT_TASK_SAVE_FP) != (OS_OPT)0) {
//OS_CPU_FP_Reg_Push(OSTCBCurPtr->StkPtr);
}
if ((OSTCBHighRdyPtr->Opt & OS_OPT_TASK_SAVE_FP) != (OS_OPT)0) {
//OS_CPU_FP_Reg_Pop(OSTCBHighRdyPtr->StkPtr);
}
#endif
2.建了两个点灯任务,现在问题是关闭FPU后,两个LED正常闪烁;开启FPU后,两个灯都被点亮,任务第一次被调用了,之后就一直运行idle任务,仿真程序没有死机,但是tick_task任务进不去,请问会是什么原因呢?有没有什么建议,谢谢。 |
|