Float and double cause hardfault handler on STM32F417

rtel wrote on Thursday, May 11, 2017:

It would have been really helpful if you had said that to start with.
If vPortPendSVHandler() was not the first thing to execute on interrupt
entry then I’m surprised it worked at all as that is the function that
performs the switch from one task to another - that means it must save a
task’s context exactly as it was when the interrupt was entered, and
performing any processing in between entering the interrupt and saving
the context that changes the context will be problematic when the task
next runs.

ophelieadveez wrote on Thursday, May 11, 2017:

I didn’t know it was the root cause. Otherwise, I would have noticed you.
Please find below my code for the interrupt. Why is it not working?

void PendSV_Handler(void)
{
    xPortPendSVHandler();
}

rtel wrote on Thursday, May 11, 2017:

xPortPendSVHandler() saves the context of the task that was interrupted

  • the context being (in part) the values held in CPU registers.
    Entering PendSV_Handler() will change the register values before
    xPortPendSVHandler() is executed, with the possibility that the register
    values saved within xPortPendSVHandler() are already corrupt.

ophelieadveez wrote on Thursday, May 11, 2017:

Thanks for the answer. But, why is it working without floating point ?

rtel wrote on Thursday, May 11, 2017:

When you use floating point instructions a bit gets set in one of the
control registers, which in turn changes the stack frame when you enter
interrupts. I would have to study the code output by the compiler to
see exactly why you were getting the symptoms you were, but it is likely
you actually have a problem in all cases but were only noticing when the
stack frame was different and/or when floating point registers
corruptions were causing faults.

ophelieadveez wrote on Friday, May 12, 2017:

Ok, thanks for your response. I fixed my problem.