AnsweredAssumed Answered

Hard fault test

Question asked by zanon.luciano on Jan 17, 2014
Latest reply on Jan 18, 2014 by Clive One
In order to test the Hard Fault interrupt, I modified the Systick example on "STM32F0xx_Discovery_FW_V1.0.0" as follows..

on main.c I added two lines:
------------------------------
int main(void)
{
uint8_t* BytePtr = (uint8_t)0x20002000;
    
    *BytePtr = 0x5a;        //generate hardfault IRQ
    
    
  /*!< ...........comment
     */     
       
  /* Initialize Leds mounted on STM32F0-discovery */
  STM_EVAL_LEDInit(LED3);
--------------------------------------

on stm32f0xx_it.c I modified the error handler:
-----------------------------------
void HardFault_Handler(void)
{
  TimingDelay_Decrement();    //really do nothing...
}
---------------------------------------

So, when the line
      *BytePtr = 0x5a;
is executed and the processor access the wrong location 0x20002000
a HardFault_Handler is called and executed.

At return I expect the processor to execute the line
  STM_EVAL_LEDInit(LED3);

but instead it returns still at line "*BytePtr = 0x5a;  and newly execute it, entering in loop!!!

I am a novice on STM32  so it must be a stupid error but if I repeat
the same test on the "STM32F10x_vldiscovery_package" it works as expected...

Can someone help me??
Thanks,
Luciano

Outcomes