cancel
Showing results for 
Search instead for 
Did you mean: 

Hard fault with BFAR=4000010 (STM32F2)

root
Associate II
Posted on January 31, 2012 at 19:46

Hello,

I have a hard fault when running my code, and the result of the hard fault is :

[Hard Fault Handler]

R0  = 4000000

R1  = 1

R2  = 20003fe0

R3  = 40013c00

R12 = 0

LR  = 8014acd

PC  = 8019474

PSR = 100022c

BFAR= 4000010

CFSR= 8200

HFSR= 40000000

DFSR= b

AFSR= 0

All values are in hexa. The thing I don't understand is that CFSR tells me there is a precise bus error and that BFSR is valid ... but the value in BFSR is obviously not valid.

It always trigger while entering a timer interrupt, which is coded as this :

void TIM2_IRQHandler(void)

{

 if (TIM_GetITStatus(TIM2, TIM_IT_Update) == SET)

 {

  TIM_ClearITPendingBit(TIM2, TIM_IT_Update);

  [a few lines of code that modify a variable]

 }

 if (TIM_GetITStatus(TIM2, TIM_IT_CC3) == SET)

 {

  TIM_ClearITPendingBit(TIM2, TIM_IT_CC3);

  [a few lines of code too, but this is never called, checked with a breakpoint]

 }

}

I use other timers with no problems, any clue on what's happening ?

Thomas.

[UPDATE] The variable I'm modifying in the interrupt is set as volatile, it seems that if I don't set this variable as volatile, the hard fault doesn't trigger. I'm using TASKING 4.0.
1 REPLY 1
Posted on January 31, 2012 at 20:11

Can you list the assembler code in proximity to the faulting PC?

Can you see anything doing a code walk of the interrupt routine, as compiled, wrt the registers at the fault.

Where are the stack pointers at, and what part or memory limits are you working with?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..