Hi
I do not get the "pflash_frdmk22f" example code from SDK 2.1 to work.
The code fails in main() after calling (line 180) :
result = FLASH_Erase(&s_flashDriver, destAdrss, pflashSectorSize, kFLASH_ApiEraseKey);
result is set to 103 meaning:
"Command is not available under current mode/security."
However I cant understand why. The flash is not in secure mode and no flash blocks are protected. I am running on my own HW and had to modify the "BOARD_BootClockRUN()" function to clock the MCU from internal instead of external clock source, other than that the code example is unchanged.
Any suggestions to what can be wrong?
Solved! Go to Solution.
I finally found the reason to the problem.
In the reference manual for K22F chapter 3.5.1.5 "Flash Program Restrictions" it is stated that the flash should not be programmed while operating in High Speed Run or VLPR power modes. As I explained in my question I changed the clock driving source (and run mode) and was running in High Speed Run mode.
Everything worked after changing to RUN mode
I finally found the reason to the problem.
In the reference manual for K22F chapter 3.5.1.5 "Flash Program Restrictions" it is stated that the flash should not be programmed while operating in High Speed Run or VLPR power modes. As I explained in my question I changed the clock driving source (and run mode) and was running in High Speed Run mode.
Everything worked after changing to RUN mode