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.
Tool/software:
Hi,
I try to erase 8 bytes of flash at a time, but the result is that one sector (1024 bytes) is erased.
Is there anything wrong with the code?
bool FLS_EraseOneWord(const uint32_t addr) { bool flashStat; DL_FlashCTL_executeClearStatus(FLASHCTL); DL_FlashCTL_unprotectSector(FLASHCTL, addr, DL_FLASHCTL_REGION_SELECT_MAIN); DL_FlashCTL_eraseMemory(FLASHCTL, addr, DL_FLASHCTL_COMMAND_SIZE_ONE_WORD); flashStat = DL_FlashCTL_waitForCmdDone(FLASHCTL); return flashStat; }
Hi Sho,
A sector is the smallest area which can be erased in MSPM0 the sector sizes are 1kB, so you won't be able to erase less than 1kB.
If you want to give more information to the use case of the 8 bytes I might be able to offer a couple different ideas/solutions to the memory management.
Regards,
Luke
Thanks for your reply soon.
I also find it in datasheet.
If you want to give more information to the use case of the 8 bytes I might be able to offer a couple different ideas/solutions to the memory management.
Yes, please show me the ideas/solutions.
Hi Sho,
If you can spare the memory space then you can increase the usage of your memory and simply cycle the data through a whole sector. Start your address at the beginning of the sector and increment the address when you perform an update. This wastes a sector of memory but it is faster than erasing and rewriting the sector every time, this also helps with the memory endurance.
If memory restricted, then you'll need to copy the sector into RAM, erase the sector, then write the previous data while masking the 8-bytes. You can then program your 8-bytes in afterwards.
Regards,
Luke