Hi 明超 戴,
You configured MSTR1 as 1. If this bit is set the descriptor is valid for bus master 1 (CPU in user state).
Do you really use MCU in user state (did you set U Control Bit in CCR register)?
If not, your MCU running in supervisor state and you should configure MSTR0 as 1 (MPUDESC0=0x80|(low_addr>>19);)
For more details about User state, please look at:
http://www.nxp.com/files/microcontrollers/doc/ref_manual/S12XCPUV2.pdf
Why do we need to config SEL?
Because there is available 8 protection descriptors and you could configure various combinations for your protection scheme. The MPUDESC0—MPUDESC5 registers are the just window to one of eight target descriptors.
You could protect various ranges in RAM, Registers, Flash, … you could define rules for CPU in user/supervisor state or XGATE,….
Attached is simple MPU example code.
BTW: If you want to protect just whole Flash against write, why you didn’t use FPROT register feature?
The command FPROT=0xA4; will enable Full P-Flash Memory Protection.
Optionally you could store FPROT value at address 0xFF0C and this value will be loaded to FPROT registers automatically after every reset.
Note: There is the potential issue with double EEC fault. Please check https://community.nxp.com/docs/DOC-93803 document for more details.
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------