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.

MSPM0G3507: How to program Flash?

Part Number: MSPM0G3507


Dear All,

I would like to program the flash memory, specifically targeting a special address such as 0x00004000. Each time I program the flash, I need to handle 64-bit data.

Currently, I am programming some calibration data, which consists of two 32-bit variables: 0x12345678 and 0x11223344.

During the first programming cycle, I wrote to address 0x00004000, setting the data to 0xFFFFFFFF_0x12345678.

For the second programming cycle, I again wrote to the same address (0x00004000), but this time I set the data to 0x11223344_FFFFFFFF.

I attempted programming on the G1306, and it was successful. However, when I tried the same process on the G3507, it failed.

My suspicion is that there might be an ECC error. If the issue indeed relates to ECC, would it be possible to disable ECC checking?

Cody

  • Hi Cody,

    ECC checking function is default enabled with the device.

    If you want to use non-ECC region, please use the below area for your flash data write and read:

    For example, use 0x0040 4000 for data storage. Be careful in all application code, there should be no read operation of 0x0000 4000 flash address. Or, you will find the ECC error occurs.

    Furthermore, you can manually update the ECC code for the data processing, and then there should be no-ECC error. The ECC data is stored at 0x4180 4000.

    B.R.

    Sal

  • Hi Sal Ye,

    I want to try writing dataArray64 into 0X00401000. The code is as follows:

    dataArray64 was not written to 0x00401000, and it shows as COMMAND_STATUS_FAILED?

    Also used this DL_FlashCTL_programMemoryFromRAM64(FLASHCTL_Regs *flashctl, uint32_t address, uint32_t *data);

    The original program could run normally on L1306, but when ported to G3507, it triggers a DED NMI due to ECC.
    Is there a way to completely disable ECC?

  • Hi Lin,

    You can just ignore ECC generation and try it with 0x00401000, and check whether it will makes the error happen.

    When you use the MAIN memory address at 0x0040 0000, which will ignore the ECC function.

    B.R.

    Sal

  • Dear Sal,

    Firstly, I would like to program 64 bits of data (0xFFFF,FFFF,1234,5678) into the address 0x00004000. Secondly, I also intend to program (0x1122,3344,FFFF,FFFF) into the same address at 0x00004000. My goal is to read the 64-bit data 0x1122,3344,1234,5678 from the address 0x00004000.

    However, I have encountered an issue. Whenever I attempt to do this, I receive the DL_SYSCTL_NMI_IIDX_FLASH_DED interrupt in the NMI_Handler. I do not wish to encounter this error status, as I intend to use this method to store my calibration data. Could you provide me with a simple example code to resolve this issue?

    Cody

  • Hi Cody,

    Use address of 0x0040 4000 instead of 0x0000 4000, inlcude both write and read operaton.

    0x0040 0000 and 0x0000 0000 are the same hardware address, but with different access method.

    Please take a try. If it does't work, I can double check with a demo code.

    B.R.

    Sal

  • Hi Sal Ye,

    Can you provide demo code? ,because i tried can't write 0x00401000,please.

  • Hi Lin,

    For the second part, can you try it with no ECC generation.

    B.R.

    Sal


  • As per the attachment

  • Hi,

    Please see my input below:

    Use 0x0000 4000 address to write, and use 0x0040 4000 address to read.

    /*
     * Copyright (c) 2021, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    #include "ti_msp_dl_config.h"
    
    uint32_t gDataArray64_1[] = {0xFFFFFFFF, 0x12345678};
    uint32_t gDataArray64_2[] = {0xABCDEF00, 0xFFFFFFFF};
    
    volatile DL_FLASHCTL_COMMAND_STATUS gCmdStatus;
    /* Address in main memory to write to */
    #define MAIN_BASE_ADDRESS (0x00004000)
    
    uint32_t gData64_1 =0;
    uint32_t gData64_2 =0;
    
    int main(void)
    {
        SYSCFG_DL_init();
    
        while (1) {
    
            /* Erase sector in main memory */
            /* Unprotect sector in main memory with ECC generated by hardware */
            DL_FlashCTL_unprotectSector(
                FLASHCTL, (0x4000), DL_FLASHCTL_REGION_SELECT_MAIN);
            /* Erase sector in main memory */
            gCmdStatus = DL_FlashCTL_eraseMemoryFromRAM(
                FLASHCTL, (0x4000), DL_FLASHCTL_COMMAND_SIZE_SECTOR);
            if (gCmdStatus == DL_FLASHCTL_COMMAND_STATUS_FAILED) {
                /* If command was not successful, set error flag */
                __BKPT(0);
            }
    
            DL_FlashCTL_unprotectSector(
                FLASHCTL, (0x4000), DL_FLASHCTL_REGION_SELECT_MAIN);
            gCmdStatus = DL_FlashCTL_programMemoryFromRAM64(
                FLASHCTL, (0x4000), &gDataArray64_1[0]);
            if (gCmdStatus == DL_FLASHCTL_COMMAND_STATUS_FAILED) {
                /* If command was not successful, set error flag */
                __BKPT(0);
            }
    
            DL_FlashCTL_unprotectSector(
                FLASHCTL, (0x4000), DL_FLASHCTL_REGION_SELECT_MAIN);
            gCmdStatus = DL_FlashCTL_programMemoryFromRAM64(
                FLASHCTL, (0x4000), &gDataArray64_2[0]);
            if (gCmdStatus == DL_FLASHCTL_COMMAND_STATUS_FAILED) {
                /* If command was not successful, set error flag */
                __BKPT(0);
            }
    
            gData64_1 = *((volatile uint32_t*) (0x00404000));
            gData64_2 = *((volatile uint32_t*) (0x00404000 + 4));
    
            __BKPT(0);
        }
    }
    

    Test result:

    B.R.
    Sal

  • Dear Sal,

    According to your method, could I implement the below-mentioned steps without interrupting FLASHSEC and FLASHDED?

    Firstly, I would like to program 64 bits of data (0xFFFF,FFFF,1234,5678) into the address 0x00004000. Secondly, I also intend to program (0x1122,3344,FFFF,FFFF) into the same address at 0x00004000. Now, should I read from 0x00404000 to get the 64-bit data 0x1122,3344,1234,5678?

    Thank you for your assistance.

    Sincerely, Cody

  • Hi Cody,

    Yes, this is exactly what I have done in the code.

    B.R.

    Sal

  • Hi Sal Ye,
    Thank you for your help.
    whenever I continue to write data to 0x4008, it always triggers DED.

  • Hi Lin,

    Also do not use memory browser to read 0x4008, use browser to read 0x0040 4008 instead.

    The read operation by memory browser, is also the same as the read in the code.

    You can find that in my screenshot, I read the 0x0040 4000 to get the data.

    B.R.

    Sal