os_cpu_a.asm中的OS_EXIT_CRITICAL PUSH {R1, R2} LDR R1, =OsEnterSum ; OsEnterSum-- LDRB R2, [R1] SUB R2, R2, #1 STRB R2, [R1] MOV R1, #0 CMP R2, #0 ; if OsEnterSum=0,enable ; interrupts如果OsEnterSum=0, IF OS_CRITICAL_INT_PRIO > 0 ; 开中断; MSREQ BASEPRI, R1 ELSE MSREQ PRIMASK, R1 ENDIF POP {R1, R2} BX LR
应该 改为 OS_EXIT_CRITICAL PUSH {R1, R2} LDR R1, =OsEnterSum ; OsEnterSum-- LDRB R2, [R1] SUB R2, R2, #1 STRB R2, [R1] MOV R1, #0 ;CMP R2, #0 CBNZ R2, OS_EXIT_CRITICAL_EXIT ; if OsEnterSum=0,enable ; interrupts如果OsEnterSum=0, IF OS_CRITICAL_INT_PRIO > 0 ; 开中断; MSR BASEPRI, R1 ELSE MSR PRIMASK, R1 ENDIF
OS_EXIT_CRITICAL_EXIT POP {R1, R2} BX LR
MSREQ PRIMASK, R1 这条语句理论上是R2等于0时才执行,但是我用ULINK仿真,发现R2不等于0,也开启了中断 |