MPU in supervisor state on S12X

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

MPU in supervisor state on S12X

Jump to solution
1,143 Views
GuillaumeDourne
Contributor I

Hi,

 

I want to use the MPU in the supervisor state.

The MPU works in the user state (by detect the MPU access Error interrupt on violation access set for the test), but when I try in supervisor state the MPU access error interrupt does not append whereas the MPUSEL_SVSEN was set to 1 as defined in the datasheet.

I tried to configure the MPU with and without the MPUSEL_SVSEN set to 1, but there is no effect.

 

Why the MPU access error interrupt does not append in the supervisor state ?

 

Example of MPU configuration :

 

#define Start_Shared_Data1 __SEG_START_SHARED_DATA1
#define End_Shared_Data1 __SEG_END_SHARED_DATA1

 

#define CPU_S12           0x40
#define CPU_XGATE         0x20
#define WRITE_DISABLE     0x80
#define EXECUTE_DISABLE   0x40

 

/* Initialization of Memory Protection unit */
  //setReg8(MPUSEL, 1 | MPUSEL_SVSEN_MASK);                  /* Select Descriptor num. 1 */
  setReg8(MPUSEL, 1);                  /* Select Descriptor num. 1 */
  U32Tmp_LowAdrress = (UINT32)Start_Shared_Data1;
  U32Tmp_HighAdrress = (UINT32)End_Shared_Data1;
  setReg8(MPUDESC2, ((UINT8)(U32Tmp_LowAdrress >> 3)));
  setReg8(MPUDESC1, ((UINT8)(U32Tmp_LowAdrress >> 11)));
  setReg8(MPUDESC0, (CPU_S12 | ((UINT8)(U32Tmp_LowAdrress >> 19))));
  setReg8(MPUDESC5, ((UINT8)(U32Tmp_HighAdrress >> 3)));
  setReg8(MPUDESC4, ((UINT8)(U32Tmp_HighAdrress >> 11)));
  setReg8(MPUDESC3, (WRITE_DISABLE | EXECUTE_DISABLE | ((UINT8)(U32Tmp_HighAdrress >>  19))));

 

 

And after this configuration is set :

 

// Enable MPU in supervisor state
  MPUSEL_SVSEN = 1;

 

 

If I change "Enable MPU in supervisor state" for "Set the CPU in User State" as follow, the MPUaccess error interrupt appends correctly as I want.

 

// Set the CPU in User State
  asm("TFR CCRH,A");
  asm("ORAA #128");
  asm("TFR A,CCRH");

 

If you have an idea, you are welcome.

Thanks. 

 

Guillaume.

Labels (1)
0 Kudos
1 Solution
402 Views
MJW
NXP Employee
NXP Employee

Hello Guillaume,

 

the descriptor in your example only covers the CPU in user state (bit 6 in MPUDESC0). To enable the descriptor for the CPU in supervisor state set bit 7 in MPUDESC0 as well.

 

MJW

Message Edited by MJW on 2010-01-14 12:32 PM

View solution in original post

0 Kudos
1 Reply
403 Views
MJW
NXP Employee
NXP Employee

Hello Guillaume,

 

the descriptor in your example only covers the CPU in user state (bit 6 in MPUDESC0). To enable the descriptor for the CPU in supervisor state set bit 7 in MPUDESC0 as well.

 

MJW

Message Edited by MJW on 2010-01-14 12:32 PM
0 Kudos