Skip to main content
MGogr.1
Senior
September 12, 2023
Question

Going to Hardfault during integrated testing

  • September 12, 2023
  • 9 replies
  • 3538 views

Hi,

I'm working with power amplifier for which I have chose stm32f407 controller which monitors ADC, I2C eeprom SPI Flash memory, ethernet , GPIOs and interrupts. when i am doing code development and standalone testing of controller no issue of hard fault is observed, but when my controller is integrated with the whole power amplifier system sometimes it goes into "HardFault" condition. this hardfault occurs mostly during uart communication. i am using uart1. Any idea on how to solve/debug this issue would be really helpful.

This are the values of registers:

CFSR = 0x8200

HFSR = 0x40000000

MMFAR = 0x1220139, 0x141012F, 0x122012F.

Any other info required feel free to ask.

This topic has been closed for replies.

9 replies

TDK
September 12, 2023

BFSR suggests PRECISE_ERR, which means you should be able to locate it.

BFAR should contain the address of the code causing the fault. You should be able to track down what exactly that is with that information. If BFAR=0x141012F, that's outside of normal memory.

Probably a write out of bounds or stack corruption or other such issue.

"If you feel a post has answered your question, please click ""Accept as Solution""."
MGogr.1
MGogr.1Author
Senior
September 14, 2023

Thanks for the reply.

Can you guide me how to locate this type of error?

I'll check once i get back the whole unit.

Tesla DeLorean
Guru
September 12, 2023

Precise would suggest a read, but might related to content written in the wrong place.

Look at the instructions at and immediately before the fault, in the context of the registers. The PC should identify the instruction, the LR where the last call will return, so prior to that the call to the failing subroutine, which can help narrow things down.

Have an effective error reporting method.  https://github.com/cturvey/RandomNinjaChef/blob/main/KeilHardFault.c

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
waclawek.jan
Super User
September 14, 2023

> when my controller is integrated with the whole power amplifier system sometimes it goes into "HardFault" condition

To me this sounds like a hardware issue: problematic power supply inadequate ground arrangement, conducted or EM interference...

JW

MGogr.1
MGogr.1Author
Senior
September 15, 2023

Hardware seems to be proper according to me.

Could this because of many peripherals running such as ADC,SPI,I2C,FreeRtos and fetching data with uart?

waclawek.jan
Super User
September 15, 2023

Everything is possible - software may take other paths if real hardware is connected, compared to any simulated environment - but IMO what I wrote above is more likely than any problem stemming only from software.

JW

TDK
September 15, 2023

If it is hardware, I would expect it to be faulting at random addresses and not the same one. Have you investigated multiple faults to ensure they're all the same or just the one?

Running many different things at once won't cause a hardfault in itself. But if your code has bugs, it can exacerbate the issue.

"If you feel a post has answered your question, please click ""Accept as Solution""."
MGogr.1
MGogr.1Author
Senior
September 16, 2023

Fault occurs only when input is given through uart  and at the same address only. when testing through Beta Analyser in Cube Programmer I got following prog.png

But I dont think I have any condition where anything is divided by zero.

Tesla DeLorean
Guru
September 16, 2023

Looking at the code and registers at the fault would be the most enlightening. 

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