This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C129ENCPDT MPU vs Hard Fault

Hello all,

I bought a http://www.ti.com/tool/ek-tm4c129exl

void hardFaultHandler()

{

  • Well, I guess my previous message was cut somehow (there was a problem with my browser?)

    I was saying that I had (not so big) issue with the MPU. Instead of the MPU fault being invoked, a hard fault is invoked. I can work around this with the code:

    void hardFaultHandler()
    {
    if(SCB->HFSR & 0x40000000 != 0 && SCB->CFSR & 0xff != 0)
    {
    /* MPU fault */
    }
    else
    {
    /* not an MPU fault */
    }
    }

    So this is not a big issue, but was wondering why is the mpuHandler not called?

    Thank you,
    Manuel
  • Hello Manuel,

    It is difficult to answer your question with knowing more details about what caused the fault, however a fault caused while executing an MPU fault routine will escalate to a hard fault. Here is an excerpt from section 2.6.2 of the data sheet:

  • Hello Bob,

    Thank you for your answer. It makes sense that the fault is being escalated to a hard fault, like you said.

    I'm having trouble figuring out why. I'm my test I purposely configure the MPU to certain memory regions and on the test, in thread mode without privileges, the test access a memory region outside the protected on the MPU (but still on RAM).

    So I guess the scenario:
    - is not the first one that you shown (because the fault happens in thread mode)
    - is not the second one (because the fault happens in thread mode)
    - is not the third one (because the fault happens in thread mode)
    - must be the fourth

    I've tried to find if I need to enable the MPU trap handler somehow, and could only find the MPUCTRL register, which is set to:
    (1U << 2U) | (0U << 1U) | (1U << 0U).

    Do you have any suggestion?

    Thank you,
    Manuel
  • Hello,

    Finally I found the answer. The MPU exception can be enabled/disabled through the SHCSR register (and this was the thing that was missing).

    Thanks again,

    Manuel