AnsweredAssumed Answered

Hard fault with BFAR=4000010 (STM32F2)

Question asked by Legrand.Thomas.001 on Jan 31, 2012
Latest reply on Jan 31, 2012 by Clive One


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

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 ?


[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.