Skip to main content
Explorer
September 12, 2023
Question

Going to Hardfault during integrated testing

  • September 12, 2023
  • 5 replies
  • 3492 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.

    5 replies

    Super User
    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.

    MGogr.1Author
    Explorer
    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.

    Graduate II
    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

    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.1Author
    Explorer
    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?

    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

    Super User
    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.

    MGogr.1Author
    Explorer
    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.

    Graduate II
    September 16, 2023

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