cancel
Showing results for 
Search instead for 
Did you mean: 

Hardfault exception in STM32F070CB

Satish M
Associate
Posted on July 06, 2018 at 11:24

Hi,

I am facing hardfault exception while running my application on STM32F070CB which is Cortex M0 based micro controller. 

The function of this MCU is to Communicate with another on board Cortex A5 based MPU via UART at 115200 baudrate and activate or deactivate the external relays based on the commands from MPU. There are some external key inputs which are monitoring by MPU. Based on these inputs, MPU will send command to MCU to activate or deactivate the external relays.  Status of the relays will be sent back to the MPU as well as a response to the commands from MPU. This communication will takes place for every 50ms. I am using one DMA channel for transmitting response in interrupt mode.  Additionally, my MCU will monitor the external signal connected to the GPIO and configured it as GPIO interrupt. All these tasks are executing in scheduling manner with the help of systick timer at 50 us. 

Application is running as expected but some times MCU is going to hardfault handler while operating external key inputs. I have disabled the watchdog feature for debugging purpose. 

When I read the stack frame, following information I got. 

Value of LR immediately after entering the hardfault exception handler is 0xFFFFFFF9. 

Stacked values at MSP are,

0xffffffff - R0

0xfffffff9 - R1

0x00000000 - R2

0xf7fef82d - R3

0x0400012d - R12

0x00000001 - LR

0xffffffff - PC

0x080038ff - XPSR

By seeing this stack frame, I understood that PC is loaded with invalid address hence, it is hardfault exception is occuring.

Can anyone please help me to solve this issue.

#cortex-m0 #stm32 #stm32f070xb #hard-fault
1 REPLY 1

Sorry, bumping old zombie unanswered questions off my feed

Add telemetry output to understand the flow and behaviour of your code so you can manually back-trace what's happening.

Write a proper Hard Fault Handler, I've posted CM0 specific ones in the past.

Make sure your stack is adequate, check for depth and coherency, and review call tree analysis from your compiler.

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