This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR6989: About the division of the segment of the FRAM

Part Number: MSP430FR6989

Hello

"Is it possible to divide the segments by setting addresses in MPUSEGB 1 and 2?
Before that, do we need to have Execute Enable, Write enable for all segments in MPUSAM?

Regards.

  • I have a question with FRAM writing.

    Now I am executing the following program. Since I set a segment and write is prohibited, I think that I can not write it, but if I do it, I can write to the FRAM area. I think that the Write Enable bit is 0 so it is write-protected. I do not know where is wrong. I'm sorry but please tell me.

    # pragma RETAIN (Tname)
    # pragma DATA_SECTION (Tname, ". infoD");
    const char Tname [8] = "trout";

    # pragma RETAIN (Udata)
    # pragma DATA_SECTION (Udata, ". infoD");
    # pragma LOCATION (Udata, 0x4400)
        int Udata [64] [8] = {,};

    main ()

       WDTCTL = WDTPW | WDTHOLD;     // Stop watchdog timer

         MPUCTL 0 = MPUPW;                     // Write PWD to access MPU registers
         MPUSEGB 1 = 0 × 1000;                  // B 1 = 0 × 10000; B 2 = 0 × 1 A 000
         MPUSEGB 2 = 0 × 1 A 00;                // Borders are assigned to segments

         MPUSAM = MPUSEG 1 RE | MPUSEG 1 XE | MPUSEG 1 WE |
                  MPUSEG 2 RE | MPUSEG 2 XE | MPUSEG 2 WE |
                  MPUSEG3RE | MPUSEG3XE |
                  MPUSEGIRE | MPUSEGIWE | MPUSEGIXE;

         MPUSAM & = ~ MPUSEG1 WE;        // Write disable
         MPUSAM & = ~ MPUSEG 2 WE;      // Write disable

    When this is done, data is written from 0x4400.
    Is this correct?

    Regards.

  • So can you please add the code where you write to the protected segment?

    Lukas
  • Hello

    I send programming code.Please check, and send advice.

    #include <msp430.h>
    #include <msp430fr6989.h>

    #include <msp430.h>

    #pragma LOCATION (Udata,0x4400)

    int Udata [32][8]={
    {0},
    {0},
    {0},};

    /*******************************************************************************
    * main.c
    ********************************************************************************/
    int main(void)
    {
    unsigned int i, j, k=0;

    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
    PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode

    MPUCTL0_H =0xA5; // Write PWD to access MPU registers
    MPUSAM |= MPUSEGIWE; // set InfoA as write enable

    MPUCTL0 = MPUPW; // Write PWD to access MPU registers
    MPUSEGB1 = 0x1000; // B1 = 0x10000; B2 = 0x1A000
    MPUSEGB2 = 0x1A00; // Borders are assigned to segments

    MPUSAM = MPUSEG1RE | MPUSEG1XE |MPUSEG1WE|
    MPUSEG2RE | MPUSEG2XE |MPUSEG2WE|
    MPUSEG3RE | MPUSEG3XE |MPUSEG3WE|
    MPUSEGIRE | MPUSEGIWE| MPUSEGIXE;

    for(i=0;i<32;i++){
    for(j=0;j<8;j++){
    Udata [i][j] = i+j+0x100;
    if(j==8){
    j=0;
    }
    }
    }

    MPUSAM &= ~MPUSEG1WE;
    MPUSAM &= ~MPUSEG2WE;

    for(i=32;i<64;i++){
    for(j=0;j<8;j++){
    Udata [i][j] = 1 + k++;
    if(j==8){
    j=0;
    }
    }
    }
    for(i=64;i<96;i++){
    for(j=0;j<8;j++){
    Udata [i][j] = 1;
    if(j==8){
    j=0;
    }
    }
    }

    while (1) {
    P1OUT ^= 0x01; // Toggle LED
    __delay_cycles(0xC00000); // Wait 16,000,000 CPU Cycles
    P9OUT ^= 0x80; // Toggle LED
    }
    }

    Regards.
  • Hello,

    You need to set the MPUENA bit to enable protection:

    MPUCTL0 = MPUPW | MPUENA;

    Best regards

    Lukas

  • Hello

    I want to divide the FRAM area into three segments.
    One of the segments performs writing and executing the program.
    The remaining 2 segments will receive new data from the host at any time and store it.

    Regards.
  • So you want to protect the segment where the code is located with MPU?
    As far as I see your code is located at 0x10000.
    So the first segment you have defined is for data storage, and the third also, correct?
    So you need to protect just segment2.

    Lukas

**Attention** This is a public forum