OSCtxSw LDR R0, =NVIC_INT_CTRL ; Trigger the PendSV excep
tion (causes context switch) LDR R1, =NVIC_PENDSVSET STR R1, [R0] BX LR[/mw_shl_code]
在ucos中,这个汇编代码应该是起到切换任务的作用吧!听说他是通过调用PendSV_Handler这个汇编函数实现任务的切换。
PendSV_Handler 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 SUBS R0, R0, #0x20 ; Save remaining regs r4-11 on process stack STM R0, {R4-R11} LDR R1, =OSTCBCur ; OSTCBCur->OSTCBStkPtr = SP; LDR R1, [R1] STR R0, [R1] ; R0 is SP of process being switched out[/mw_shl_code]
可是我还是不懂,OSCtxSw这个函数怎么就触发PendSV_Handler函数的?
NVIC_INT_CTRL他的宏定义应该是指一个寄存器的地址把,改一下寄存器的值就可以触发中断了?