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: Flash API Issue

Part Number: MSPM0G3507

Tool/software:

Hi  team,

Driverlib provides some API for writing flash (such as programCacheFromRAM8WithECCGenerated), but they are all within 4 bytes. Is there a recommended solution for writing in large quantities? Do you need to check certain states?

Thanks & Best regards,

Jiahui

  • Hello Jiahui,

    You can refer to the example code "flashctl_multiple_size_write_LP_MSPM0G3507" and you can find more API of flash control such as: 

    And about the description of Flash control, you can refer to the sector 6.1 NVM overview in the TRM.

    Best Regards,

    Janz Bai

  • Hi Janz

    Thanks for your quick reply.

    In this case, only up to 8 bytes can be written.
    But we will have a large number of writes, such as 128KB packets. What interface should be used or what design solution should be recommended for this situation? Is it a direct loop call to an interface written in 8 bytes?

  • Hi Janz,

    Any updates?

    Thanks & Best regards,

    Jiahui

  • Hello Jiahui,

    Sorry for the late reply, I am on my National Day holiday from 28th Sep to 7th Oct. 

    In fact, 64bit data (plus 8 ECC bits) is a single Flash word. All device support single flash word programming at a time and some devices additionally have support for a multi-word programming mode where 2, 4 or 8 flash words can be written with a single commanded operation, but MSPM0G3507 can't. 

    Up to 64-bit data (plus 8 ECC bits) can be written to Flash at a time.

    If you want to write more data, you need to write multiple times.

    Best Regards,

    Janz Bai 

  • Hi Janz,

    Do we need to call the interface in driverlib ourselves to perform loop writing? Please help confirm if the following writing method is acceptable, and if it is recommended to check more statuses to confirm successful writing


    In the SDK, there is already a layer of ADC, I2C, etc. encapsulated in the driver. Is there any relevant arrangement for Flash, which will be reflected in the subsequent new version of the SDK for everyone to use? As shown in the following figure

    Thanks & Best regards,

    Jiahui

  • Hello Jiahui,

    Your basic logic is right but there are some points need to be paid attention to:

    1). Before you write data to flash, you need to erase a flash region firstly, our M0 erasing region size is sector (1 KB) or bank (whole flash). I think one sector is enough for you but if you want to use more sectors, you can erase more sectors through modifying the bass address of this function. I recommend the base address is as 0x400, 0x800, 0xC00, tec because one flash sector is 1 KB (1024 Bytes).

    2). M0 flash have a protection function. 

    So before your writing to flash or erasing flash, you need to unprotect the sector in main memory. The function is:

    This function will unprotect the sector which the "MAIN_BASE_ADDRESS" belongs to. 

    3). You don't need to modify the value of "u32TargetAddress" in the unprotect function if you do flash operation in the same one flash sector. 

    You are right to add 8 to the "u32TargetAddress" in the RAM64WithECCGenerated every time.

    4). If the u32LenTemp is used to calculate the amount of Bytes, -8 is ok. If this variable is used to calculate the amount of other format, you need to modify it.

    5). How it is a good method to refer to the example code" flashctl_multiple_size_write" in our SDK and you can find all the functions you need in the "dl_flashctl.h" and "dl_flashctl.c" files. About the related registers of FLASH control, you can find them in the TRM. Try to debug your code in debug mode in CCS which can help you find any small error which may be ignored when you write the code.

     

    I don't remember that we have plan to generate the drivers for FLASH control. I can discuss and ask my colleague to confirm it.

    Best Regards,

    Janz Bai