I want to use MTB_DWT to monitor stack overflow and underflow on a S32K1x mcu (cm0+). I think (no evidence from ref manual) that DWT is accessible only throught the DAP interface and not from the processor.
In order to do so I "reserve" an empty buffer at the bottom of the stack and configure the MTB watchpoint for the address range for starting trace in case of access in that range.
Unfortunately, MTB is not able to trigger exceptions, so my approach is the following: I protect the SRAM_L area with the MPU and catch the exception (I did not check yet if MPU raises exceptions-- any hin on this?)
On S32K11x, I can see that the MPU is enabled out of reset with Region0 configured as:
WORD0 = 0x00000000
WORD1 = 0xFFFFFFFF
WORD2 = 0x0001F7DF
WORD3 = 0x00000001
I want to reconfigure region0, so I clear the bit in CSER[VLD] and update access control rights such as WORD3[VLD] is cleared.
But then writing to the RGD.WORD0 and RGD.WORD1 trigger an hard fault, even if the two VLD field are cleared.
Writing to REG1 does not raise any error.
Updating the region1 descriptor does not trigger any error.
any hint on this point?
Thanks and best regards,
Edit: BTW, the example MPU_memory_protection from the SDK v3 does not trigger any error, the MPU_DRV_GetDetailErrorAccessInfo returns always a null value.
One more question about the MPU example from the SDK: according to the ref manual, pag. 261:
As shown in the third condition, granting permission is a higher priority than denying
access for overlapping regions
So the region0 configuration from the SDK should NEVER raise an error. Am I right?