MPC5744 Registers Protection

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

MPC5744 Registers Protection

1,137 Views
ahmedsoubky
Contributor II

Hello,

According to the MPC5744 reference manual REG_PROT is a generic module and the mechanisms explained apply to different microcontroller registers sets.

As the generic explanation is hard to apply on specific modules, would you please provide example code how to enable the hard lock on any peripheral  ( for instance SPI or any other module).

Thanks in advance,

Best Regards

Labels (1)
0 Kudos
1 Reply

863 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

here is a piece of code that I found in my repository. Originally it was written for MPC5604E but it's the same for MPC5744P. Used header file is attached. It's just test code to see how it works:

    unsigned int lock = 0;

    //just write something to DSPI_A.MCR register to see we can write the register
    DSPI_A.MCR.R = 0xFFFFFFFF;
    DSPI_A.MCR.R = 0x00000000;
    
    //get the lock status of this register. It will be zero because protection is not active
    GET_SOFTLOCK(DSPI_A.MCR.R, lock);
    
    //write new value to register and lock the register for further access
    DSPI_A.MCR.R = WRITE_WITH_LOCK32(DSPI_A.MCR.R,0xFFFFFFFF);
    
    //this write will not work because register is protected
    DSPI_A.MCR.R = 0x00000000;
    
    //get the lock status - it will be 0x0F - all four bytes are locked
    GET_SOFTLOCK(DSPI_A.MCR.R, lock);
    
    //clear the lock bits
    CLR_SOFTLOCK32(DSPI_A.MCR.R);
    
    //we can write the register again
    DSPI_A.MCR.R = 0x00000000;
    
    //get the lock status - it will be zero, protection is not active
    GET_SOFTLOCK(DSPI_A.MCR.R, lock);
    
    //set lock
    SET_SOFTLOCK32(DSPI_A.MCR.R);
    
    //try to write the register - it will not work
    DSPI_A.MCR.R = 0xFFFFFFFF;
    
    //and check status...
    GET_SOFTLOCK(DSPI_A.MCR.R, lock);

Regards,

Lukas