AnsweredAssumed Answered

Hard Fault-> INVALID STATE when calling WFI() STM32L

Question asked by ampa on Jul 31, 2014
Latest reply on Feb 23, 2015 by cemer

I hit an issue with our STM32L project that is giving meheadaches.

 

We have recently upgraded from STM32L151VB to STM32L151VC as we needed the extra RAM.

Migrating the code though, has started triggering HARDfaults with the Invalid state flag set in the CFSR. It just so happens when calling the _WFI() instruction to go to sleep.

(using IAR 7.10.3). The problemdisappears if I put a breakpoint before or on the WFI operation ( see addr  0x800bc1e in disassembly dump ). The problem occurs again in a different location if I modify the code and the binary moves around. 

  Dis%20SxS.png

 

I have implemented a hard fault handler as suggested by joseph yiu, but the contents of the recovered stack do not tell me much as it looks to be coming from some other interrupt or fault (LR), the PC is invalid (EVEN)

 

[Hard fault handler - all numbers in hex]

 

R0       = 0x0

 

R1       = 0xe000ed10

 

R2       = 0x1000

 

R3       = 0x66000000

 

R12      = 0xe5ffffff

 

LR [R14] = 0xfffffff9  subroutine call return address

 

PC [R15] = 0x7000  program counter

 

PSR      = 0x6000002a

 

BFAR     = 0xe000ed38

 

CFSR     = 0x00020000

 

HFSR     = 0x40000000

 

DFSR     = 0x1

 

AFSR     = 0x0

 

SHCSR    = 0x0

 

Forced Hard Fault

 

Usage fault: INV STATE


I have examined all the interrupt vector entries, they all seem to be on an odd address as expected…

Do anybody have any ideas at all?


I have implemented a hard fault handler as suggested by joseph yiu, but the contents of the recovered stack do not tell me much as it looks to be coming from some other interrupt or fault (LR), the PC is invalid (EVEN)

[Hard fault handler - all numbers in hex]

R0       = 0x0

R1       = 0xe000ed10

R2       = 0x1000

R3       = 0x66000000

R12      = 0xe5ffffff

LR [R14] = 0xfffffff9  subroutine call return address

PC [R15] = 0x7000  program counter

PSR      = 0x6000002a

BFAR     = 0xe000ed38

CFSR     = 0x00020000

HFSR     = 0x40000000

DFSR     = 0x1

AFSR     = 0x0

SHCSR    = 0x0

Forced Hard Fault

Usage fault: INV STATE


I have implemented a hard fault handler as suggested by joseph yiu, but the contents of the recovered stack do not tell me much as it looks to be coming from some other interrupt or fault (LR), the PC is invalid (EVEN)

[Hard fault handler - all numbers in hex]

R0       = 0x0

R1       = 0xe000ed10

R2       = 0x1000

R3       = 0x66000000

R12      = 0xe5ffffff

LR [R14] = 0xfffffff9  subroutine call return address

PC [R15] = 0x7000  program counter

PSR      = 0x6000002a

BFAR     = 0xe000ed38

CFSR     = 0x00020000

HFSR     = 0x40000000

DFSR     = 0x1

AFSR     = 0x0

SHCSR    = 0x0

Forced Hard Fault

Usage fault: INV STATE


I have implemented a hard fault handler as suggested by joseph yiu, but the contents of the recovered stack do not tell me much as it looks to be coming from some other interrupt or fault (LR), the PC is invalid (EVEN)

[Hard fault handler - all numbers in hex]

R0       = 0x0

R1       = 0xe000ed10

R2       = 0x1000

R3       = 0x66000000

R12      = 0xe5ffffff

LR [R14] = 0xfffffff9  subroutine call return address

PC [R15] = 0x7000  program counter

PSR      = 0x6000002a

BFAR     = 0xe000ed38

CFSR     = 0x00020000

HFSR     = 0x40000000

DFSR     = 0x1

AFSR     = 0x0

SHCSR    = 0x0

Forced Hard Fault

Usage fault: INV STATE


Outcomes