cancel
Showing results for 
Search instead for 
Did you mean: 

multiple interrupt hard fault

EPora.1
Associate II

Hello,

I'm using an stm32f411ce in an application that includes an external interrupt, a uart DMA TF interrupt and a systick interrupt. with the external interrupt in the highest priority and the systick in the lowest respectively. The code runs for a few seconds and then goes to a hard fault. and ideas?

Thanks,

Eyal

EDIT:

Also, I have seen somewhere that it may be an unaligned memory that is causing the error so I have set the stack align bit like this:

SCB ->CCR |= (1 << 9); //set stack align

but the processor doesn't seems to get the command

0693W00000GZTkMQAX.png and there is no button for setting it which there should be

4 REPLIES 4

>>any ideas?

Look at what is ACTUALLY faulting..

Instrument your code so you know what happens, and the flow involved.

Check stack depth.

Check you're not using transient buffers for DMA.

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

In the fault report window with ARM compiler 6 and -O1 optimization it says that it is a bus fault, specifically IBUSERR. when the optimization is at -O0 it says that it's a memory fault; IACCVIOL. Both's description says that it can be either an invalid return due to corrupted stack or an incorrect entry in the exception vector table

simosilva
Senior

I saw this problem many times when an incorrect IRQ enter when another one is served, causing bad push and pop in the stack, tipically resulting into a read on the address specified by some content of other registers coming from the bad pop, if this reads a protected memory region you clearly have the bus/memory hard fault.

In debug, placing a __BKPT() into the hard fault (or even into the IRQ handler that causes the fault) and then looking into the call stack you will have a more clear view.

Hello, thanks for your answer!

I have tried that and it seems that the code crashes every time on this function which is inside an interrupt routine:

void Quaternion::normalize()
{
  float n = magnitude();
  c[0] /= n;
  c[1] /= n;
  c[2] /= n;
  c[3] /= n;
}

and the fault seems to be a usage instruction error.