diff options
| author | aozima <[email protected]> | 2018-07-24 16:08:56 +0800 |
|---|---|---|
| committer | aozima <[email protected]> | 2018-07-25 21:39:43 +0800 |
| commit | a0fe71f78f14cb653f4bc219842c9a6a2914766e (patch) | |
| tree | 867e536659a8b4e0b954d3e673225382c2be48e6 | |
| parent | 2316dc3f0f3d49333335bfb107ecc68bbb1843d5 (diff) | |
fixed get sp in HardFault_Handler. close #1646
| -rw-r--r-- | libcpu/arm/cortex-m3/context_rvds.S | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/libcpu/arm/cortex-m3/context_rvds.S b/libcpu/arm/cortex-m3/context_rvds.S index a4191203be..9a7ff10abe 100644 --- a/libcpu/arm/cortex-m3/context_rvds.S +++ b/libcpu/arm/cortex-m3/context_rvds.S @@ -1,7 +1,7 @@ ;/* ; * File : context_rvds.S ; * This file is part of RT-Thread RTOS -; * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team +; * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team ; * ; * The license and distribution terms for this file may be ; * found in the file LICENSE in this distribution or at @@ -186,14 +186,17 @@ HardFault_Handler PROC ; get current context TST lr, #0x04 ; if(!EXC_RETURN[2]) - MRSNE r0, msp ; get fault context from handler. - MRSEQ r0, psp ; get fault context from thread. + ITE EQ + MRSEQ r0, msp ; [2]=0 ==> Z=1, get fault context from handler. + MRSNE r0, psp ; [2]=1 ==> Z=0, get fault context from thread. STMFD r0!, {r4 - r11} ; push r4 - r11 register STMFD r0!, {lr} ; push exec_return register - MSRNE msp, r0 ; update stack pointer to MSP. - MSREQ psp, r0 ; update stack pointer to PSP. + TST lr, #0x04 ; if(!EXC_RETURN[2]) + ITE EQ + MSREQ msp, r0 ; [2]=0 ==> Z=1, update stack pointer to MSP. + MSRNE psp, r0 ; [2]=1 ==> Z=0, update stack pointer to PSP. PUSH {lr} BL rt_hw_hard_fault_exception |
