cancel
Showing results for 
Search instead for 
Did you mean: 

Going to Hardfault during integrated testing

MGogr.1
Associate III

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.

9 REPLIES 9
TDK
Guru

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

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
Up vote any posts that you find helpful, it shows what's working..
MGogr.1
Associate III

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.

> 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

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?

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
Guru

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
Associate III

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.

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

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