Other Parts Discussed in Thread: MSPM0L1306, SYSCONFIG
Tool/software:
hi, experts:
I'd like to save a structure in flash, so I'll use sizeof() to get the bytes of the struct, then save the bytes in flash, I wonder how to do this? Can I do like below? Also I want to know the start address where I can save user data in flash, thanks.
Bill
/*
* Ensure proper flash command execution by clearing the STATCMD
* register before executing a flash operation
*/
DL_FlashCTL_executeClearStatus(FLASHCTL);
/* Unprotect sector in main memory*/
DL_FlashCTL_unprotectSector(
FLASHCTL, addr, DL_FLASHCTL_REGION_SELECT_MAIN);
/* Erase sector in main memory */
gCmdStatus = DL_FlashCTL_eraseMemoryFromRAM(
FLASHCTL, addr, DL_FLASHCTL_COMMAND_SIZE_SECTOR);
if (gCmdStatus == DL_FLASHCTL_COMMAND_STATUS_FAILED) {
/* If command was not successful, set a breakpoint */
__BKPT(0);
}
/*
* Ensure proper flash command execution by clearing the STATCMD
* register before executing a flash operation
*/
DL_FlashCTL_executeClearStatus(FLASHCTL);
/* 8-bit write to flash in main memory without ECC */
DL_FlashCTL_unprotectSector(
FLASHCTL, addr, DL_FLASHCTL_REGION_SELECT_MAIN);
for(i = 0; i < size; i++)
{
gCmdStatus = DL_FlashCTL_programMemoryFromRAM8(
FLASHCTL, addr, v + i);
if (gCmdStatus == DL_FLASHCTL_COMMAND_STATUS_FAILED) {
/* If command was not successful, set a breakpoint */
__BKPT(0);
}
}