How to enter into supervisor mode and user mode in MPC5675K MCU?

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

How to enter into supervisor mode and user mode in MPC5675K MCU?

Jump to solution
2,245 Views
mohammedshibin
Contributor I

Hi,

 

How to enter into supervisor mode and user mode in MPC5675K and how to access CPU special function registers such as MSR(Machine State Register)?

 

Regards,

Mohammed Shibin

Labels (1)
0 Kudos
1 Solution
1,284 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Screenshot_2.png

Access to MSR and SPR register must be done indirectly with using of mtmsr/mfmsr and mtmsr/mfmsr. Sometimes I am using macros below where ‘address’ points to variable where data are being written from/are read to. Or you can use pure assembler code.

/************** macro for MSR WRITE **************/

// param 'address' is a variable name (thus its address)

#define WRITE_TO_MSR(address)            \

asm (lis r30, (address)@h);              \

asm (ori r30, r30, (address)@l);         \

asm (lwz r31, 0x0(r30));                 \

asm (mtmsr r31);

/************** macro for MSR READ **************/

// param 'address' is a variable name (thus its address)

#define READ_FROM_MSR(address)           \

asm (lis r30, (address)@h);              \

asm (ori r30, r30, (address)@l);         \

asm (mfmsr r31);                         \

asm (stw r31, 0(r30));

View solution in original post

0 Kudos
1 Reply
1,285 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Screenshot_2.png

Access to MSR and SPR register must be done indirectly with using of mtmsr/mfmsr and mtmsr/mfmsr. Sometimes I am using macros below where ‘address’ points to variable where data are being written from/are read to. Or you can use pure assembler code.

/************** macro for MSR WRITE **************/

// param 'address' is a variable name (thus its address)

#define WRITE_TO_MSR(address)            \

asm (lis r30, (address)@h);              \

asm (ori r30, r30, (address)@l);         \

asm (lwz r31, 0x0(r30));                 \

asm (mtmsr r31);

/************** macro for MSR READ **************/

// param 'address' is a variable name (thus its address)

#define READ_FROM_MSR(address)           \

asm (lis r30, (address)@h);              \

asm (ori r30, r30, (address)@l);         \

asm (mfmsr r31);                         \

asm (stw r31, 0(r30));

0 Kudos