Hard Fault exception

joe_her wrote on Wednesday, February 13, 2019:

I get a Hard Fault exception whil progrma is running.
Call stack is not much help (attched)
Is there a better way to hunt this?
Thanks

waveringradiant wrote on Wednesday, February 13, 2019:

This is probably a good place to start, FreeRTOS article on debugging hard faults.

neicdech wrote on Wednesday, February 13, 2019:

Most hardfault comes from the processor trying to access a peripheral which has not not been properly initialised. for instance , you forgot to enable the clock to a peripheral. Or accessing invalid memory or something you forgot to do. so step through the code and see where the fault comes from.

waveringradiant wrote on Wednesday, February 13, 2019:

Most hardfault comes from the processor trying to access a peripheral which has not not been properly initialised. for instance , you forgot to enable the clock to a peripheral. Or accessing invalid memory or something you forgot to do. so step through the code and see where the fault comes from.

I’m not sure I’d agree with that… some of the many, many examples that can cause hard fault include:

  • stack overflow
  • pointer corruption
  • uninitialized pointer (from OP’s picture I suspect this might be the case)
  • handling for disabled exceptions, e.g.,unprivileged access, MPU, bus fault

Here the SCB’s HFSR (0xE000ED2C) will give you some hints. If you step through pvPortStartFirstTask(), I suspect that a pointer that you are responsible for isn’t set up correctly.

Goodl luck. Let us know if you discover the issue or if you have further clues/details