SPRADN2 January   2025 MSPM0G1518 , MSPM0G1519 , MSPM0G3518 , MSPM0G3519 , MSPM0L1227 , MSPM0L1228 , MSPM0L2227 , MSPM0L2228

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1Nonvolatile Memory (NVM) Basic Introduction
    1. 1.1 Flash Memory Protection
  5. 2Customer Secure Code (CSC) Introduction
    1. 2.1 CSC Execution Overview
    2. 2.2 CSC Memory Maps
    3. 2.3 CSC Execution Process
  6. 3Bank Swap Example Implementation
    1. 3.1 CSC Code Project Preparation
      1. 3.1.1 Enable CSC in NONMAIN
      2. 3.1.2 Implementation of CSC Application Code - Bank Swap Feature
    2. 3.2 Application Code Project Preparation
  7. 4Common Use Case Introduction
  8. 5Data Bank Introduction
    1. 5.1 Data Bank Protection
    2. 5.2 Data Bank Erase Write Operation
  9. 6Summary
  10. 7References

Data Bank Erase Write Operation

The erase and write operation on DATA bank are identical to the MAIN region, and can be called from Flash. Erase can happen at set or bank granularity. These feature makes the DATA bank as an excellent design for data logging. Please find a more detailed description in the device technical reference manual. An example how to use the DATA bank is shown below.

/* Address in DATA memory to write to */
#define DATA_BASE_ADDRESS (0x41D00000)
bool status = false;
uint8_t gData8 = 0x11;

    DL_FlashCTL_unprotectSector(
            FLASHCTL, DATA_BASE_ADDRESS, DL_FLASHCTL_REGION_SELECT_MAIN);
    DL_FlashCTL_eraseMemory(
            FLASHCTL, DATA_BASE_ADDRESS, DL_FLASHCTL_COMMAND_SIZE_SECTOR);
    status = DL_FlashCTL_waitForCmdDone(FLASHCTL);    
    while(status == false){};

    DL_FlashCTL_unprotectSector(
            FLASHCTL, DATA_BASE_ADDRESS, DL_FLASHCTL_REGION_SELECT_MAIN);
    DL_FlashCTL_programMemory8WithECCGenerated(
            FLASHCTL, DATA_BASE_ADDRESS, &gData8);