Hi, to all!
I have a problem with my card realized with KL27Z256 using flash memory for storing parameters. (KDS Mainline SDK 3.0.0 + 1.2.0)
I followed the demo attached to the package SDK 1.2.0 Mainline, made for KL24Z64.
For several days I'm working, but I managed to write and delete only addresses equal to or greater than 0x20000, in the second block of flash then.
I need to be able to use an address in the first 128K and here the problems begin, because in this case the processor reset continuously, and the write / erase are unsuccessful.
I note that, as indicated by the demo, I copied in the ram "CommandSequence" and the "CallBack" (which is empty).
I enclose lines of code involved and screen component inspector.
void
Store_Param(void)
{
StartFlashAddr = K_StartFlashAddr; // 0x20000
Size = K_SectorSize; // 0x0400
flash1_InitConfig0.CallBack = (PCALLBACK)RelocateFunction((uint32_t)__ram_for_callback , CALLBACK_SIZE , (uint32_t)flash1_Callback);
MyCommandSequence = (pFLASHCOMMANDSEQUENCE)RelocateFunction((uint32_t)__ram_func , LAUNCH_CMD_SIZE, (uint32_t)FlashCommandSequence);
ret = FlashEraseSector(&flash1_InitConfig0, StartFlashAddr, Size, MyCommandSequence);
ParamSet.Cks = Calc_CKS((byte *)&ParamSet, sizeof(ParamSet) - 1);
Size = sizeof(ParamSet);
ret = FlashProgram(&flash1_InitConfig0, StartFlashAddr, Size, (byte*)&ParamSet, MyCommandSequence);
f_To_Save = FALSE;
} // Store_Param
Solved! Go to Solution.
Hello Paolo Colombo:
In your configuration the Program Flash size is incorrect, it should be 0x00040000 instead of 0xFFFFFFFF.
To resolve the reset problem, try enabling the ESFC bit as instructed by colleague Jennie Zhang in her document:
Using ESFC bit - Flash programming routines in Cotex M0+ kinetis MCU
Just add this line of code:
MCM_PLACR |= MCM_PLACR_ESFC_MASK;
Refer to the attached code for an example, which erases and writes data to the last sector in block 0.
Let me know if the problem persists.
Regards!,
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Paolo Colombo:
In your configuration the Program Flash size is incorrect, it should be 0x00040000 instead of 0xFFFFFFFF.
To resolve the reset problem, try enabling the ESFC bit as instructed by colleague Jennie Zhang in her document:
Using ESFC bit - Flash programming routines in Cotex M0+ kinetis MCU
Just add this line of code:
MCM_PLACR |= MCM_PLACR_ESFC_MASK;
Refer to the attached code for an example, which erases and writes data to the last sector in block 0.
Let me know if the problem persists.
Regards!,
Jorge Gonzalez
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Congratulations !!! I solved this problem immediately !!!
The problem was right:
MCM_PLACR |= MCM_PLACR_ESFC_MASK;
Thank you very much, you are a magician!