AnsweredAssumed Answered

How to config MPU register

Question asked by 明超 戴 on Jul 4, 2016
Latest reply on Jul 12, 2016 by 明超 戴


     I am using MPU mechanism in order to protect Pflash.The processor is MC9S12XEP100 and compile environment is Codewarrior. the global section which I want to protect is from 0x7FE000-0x7FFFFF,I want to set this section can not be config as fellows:

void mpu_init(void) {

    unsigned long low_addr=0x7FE000;

    unsigned long high_addr=0x7FFFFF;


    MPUDESC0=0x40|(low_addr>>19);       //CPU in user state   low_addr:22-19

    MPUDESC1= (unsigned char)((low_addr&0x7FFFF)>>11);//low_addr:18-11

    MPUDESC2= (unsigned char)((low_addr&0x7FF)>>3);//low_addr:10-2

    MPUDESC3= 0x80|(high_addr>>19);//WP NEX  high_addr:22-19

    MPUDESC4= (unsigned char)((high_addr&0x7FFFF)>>11);//high_addr:18-11

    MPUDESC5= (unsigned char)((high_addr&0x7FF)>>3);//high_addr:10-2

    MPUSEL=0x80|MPUSEL;    //SVSEN=1,SEL=01;


after config  I found the MPU can not work . I need your help .I could not Understand why we need to config SEL.

could you give me some advise or demo .

                                                            thank you!