I'm using a KL16 with MCUXpresso 10.2 and I'm able to store/write/read my variables to flash (in the last 2KB of the 64KB using Flash_Program(...)). Is there a setting to block MCUXpresso or the debugger from erasing these variables when reprogramming new firmware?
I've tried to create a new flash region in the last 2KB using the Memory Configuration Editor but my variables get erased.
Solved! Go to Solution.
Hi Brett,
Yes, you can use "Non-Volatile Memory Preservation" :
If you want protect 0xF800- 0xFFFF , you can configure as below:
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Sorry, I'm using a PE Multilink Universal FX. I've defined the two sections:
Name Location Size
Program_Flash 0x0 0xF800
Variable_Flash 0xF800 0x800
You mentioned I have to ensure the flash operation does not use mass erase. Is this through the "Edit Configuration" of the ....PE Debug.launch (under the doc folder in the Project Explorer)?
I see there is a "Non-Volatile Memory Preservation" under Debugger, Advanced Options.
Hi Brett,
Yes, you can use "Non-Volatile Memory Preservation" :
If you want protect 0xF800- 0xFFFF , you can configure as below:
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
You didn't mention which debugger you're using, but the same principles apply. The K16 sector size is 1 KB. A sector is typically the smallest programmable/erasable block of memory. In order to get this to work, you need to redefine the flash memory into two flash blocks. It sounds like you've already done this.
The memory range of the first block is now 0x00000000-0x00007FFF. The memory range of the second block is 0x00008000-0x0000FFFF.
You have to ensure the flash operation does not use mass erase. Most debuggers (e.g. MCUXpresso) allow you to erase by sector.
Thanks and regards,
MCUXpresso Support
EDIT: Sorry, you said 2 KB persistent storage. In this case, the memory range of the first flash block is 0x00000000-0x0000F7FF, and the second is 0x0000F800-0x0000FFFF.