How to enable MemManage_Handler when MPU violation happens?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to enable MemManage_Handler when MPU violation happens?

3,134 Views
anita_tranzillo
Contributor I

Hello, I have a problem wih MPU.

I'm using S32K144 uC.

I'm using MPU to detect stack overflow/underflow.

I have enabled MPU protection for two regions which surrounds the stack. 

After this, I enable MemManage_Handler and then the MPU, like this:

    S32_SCB->SHCSR |= 1<<16;
    MPU->CESR |= MPU_CESR_VLD_MASK;

The problem is that when I try to write in a protected region, HardFault exception Always occurs.

Do you have experience on this issue?

Is there any restriction to enable MemManage exception?

I have also redefined MemManage handler

void MemManage_Handler(void)

{
  FailureCbk();

since I need to apply a recovery action.

I hope you will help me

1 Reply

2,805 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello Anita,
MemManage exceptions rise on an attempt to access regions that are protected by the core ARM Cortex M4 Memory Protection Unit.
However, the S32K144 MCU implements its own system Memory Protection Unit on the bus and therefore an attempt to access a protected region results in a bus fault exception instead.

pastedImage_1.png

BR, Daniel