Hi,
I am a beginner studying how to use the K64F. I would like to write some data into the non volatile memory, so that when I restart the board, the data would still be there. I was already able to run the flash demo which came with the SDK (I am using KDS). I guess I would have to use FlashProgram, like
ret = FlashProgram(&flashSSDConfig, destination, PGM_SIZE_BYTE, DataArray, g_FlashLaunchCommand);
However, what would be a valid value for the destination? Is there any documentation which says which part of the memory I should use for storing my data? Also I noticed that the K64F has no DFlash, does that mean that arbitrary data cannot be stored in the flash memory, only the program itself?
Thanks! ^_^
Solved! Go to Solution.
Hello Rinoa Harasashi:
Typically configuration data is placed at the end of the flash (higher addresses) because application grows from lower addresses. You need to reserve at least one flash sector at the end of flash; for K64 the flash sector size is 4KB.
You can check the generated .map file to see how much memory your code is using and also a very useful feature is to print the code size. The next tutorial explains how to activate "Print Size" with KDS:
GNU Additional Tools: Create Flash Image, Print Size and Extended Listing Options | MCU on Eclipse
The material and examples in the next links will help you understand how to reserve space in flash using the GCC linker file and allocate your Non Volatile data to such space:
Controlling data and function placement in memory
Relocating Code and Data Using the CW GCC Linker File for Kinetis
Defining Variables at Absolute Addresses with gcc | MCU on Eclipse
Some points to consider:
- K64FX512 has FlexNVM memory to be used as EEPROM, while K64FN1M0 only has P-Flash. I don't know which is yours.
- If you intend to frequently update the constant data, you better reserve more than 1 flash sector and alternate programming addresses. This way you do not overuse a single flash space due to its program cycles.
- When calling the program flash routines (Program Phrase command), make sure that the address is aligned to 64 bits.
Regards!,
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Rinoa Harasashi:
Typically configuration data is placed at the end of the flash (higher addresses) because application grows from lower addresses. You need to reserve at least one flash sector at the end of flash; for K64 the flash sector size is 4KB.
You can check the generated .map file to see how much memory your code is using and also a very useful feature is to print the code size. The next tutorial explains how to activate "Print Size" with KDS:
GNU Additional Tools: Create Flash Image, Print Size and Extended Listing Options | MCU on Eclipse
The material and examples in the next links will help you understand how to reserve space in flash using the GCC linker file and allocate your Non Volatile data to such space:
Controlling data and function placement in memory
Relocating Code and Data Using the CW GCC Linker File for Kinetis
Defining Variables at Absolute Addresses with gcc | MCU on Eclipse
Some points to consider:
- K64FX512 has FlexNVM memory to be used as EEPROM, while K64FN1M0 only has P-Flash. I don't know which is yours.
- If you intend to frequently update the constant data, you better reserve more than 1 flash sector and alternate programming addresses. This way you do not overuse a single flash space due to its program cycles.
- When calling the program flash routines (Program Phrase command), make sure that the address is aligned to 64 bits.
Regards!,
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thank you very much! ^_^
Hi,
Please, send your post to kinetis community (e.g. Kinetis Microcontrollers ) to get it visible for active members.
Regards
Soledad