Hi,
I am working on a project with a custom board running an MK22FN128VLH10. Now I need to add an NVM parameter area in flash but I can't get the flash erasing and writing to work.
I am aware that I have to run the actual flash sequence from ram and that interrupts needs to be disabled while doing it since I only have one block of flash.
I am using KDS v3.0.0, KSDK 1.3.0 and the fsl_flash component with processor expert and this is what I have come up and running in main for testing, what else is needed?
uint32_t result; /*! Return code from each SSD function */
uint32_t destAdrss; /*! Address of the target location */
pFLASHCOMMANDSEQUENCE g_FlashLaunchCommand = (pFLASHCOMMANDSEQUENCE)0xFFFFFFFF;
uint16_t ramFunc[LAUNCH_CMD_SIZE/2]; // Array to copy __Launch_Command func to RAM.
// Copy FlashCommandSequence() function to ramFunc array.
g_FlashLaunchCommand = (pFLASHCOMMANDSEQUENCE)RelocateFunction((uint32_t)ramFunc , LAUNCH_CMD_SIZE ,(uint32_t)FlashCommandSequence);
// Erase a sector from destAdrss.
destAdrss = DataFlash_InitConfig0.PFlashBase + (DataFlash_InitConfig0.PFlashSize - 2*FTFx_PSECTOR_SIZE);
INT_SYS_DisableIRQGlobal(); // Make sure nothing touches flash block 0 while erasing.
result = FlashEraseSector(&DataFlash_InitConfig0, destAdrss, FTFx_PSECTOR_SIZE*2, g_FlashLaunchCommand);
INT_SYS_EnableIRQGlobal();
if (FTFx_OK != result)
{
while(1);
}
Can't seem to get code formatting to work here...