2023-09-11 09:31 PM
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.
2023-09-12 06:34 AM - edited 2023-09-12 06:36 AM
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.
2023-09-12 06:48 AM
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
2023-09-13 08:51 PM
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.
2023-09-13 11:42 PM
> 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
2023-09-14 10:16 PM
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?
2023-09-15 12:02 AM
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
2023-09-15 07:06 AM
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.
2023-09-15 10:20 PM
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
But I dont think I have any condition where anything is divided by zero.
2023-09-16 04:06 AM
Looking at the code and registers at the fault would be the most enlightening.