Problems using internal flash in MK22F

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Problems using internal flash in MK22F

跳至解决方案
1,128 次查看
olavbirkeland
Contributor III

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?

0 项奖励
回复
1 解答
999 次查看
olavbirkeland
Contributor III

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

在原帖中查看解决方案

0 项奖励
回复
1 回复
1,000 次查看
olavbirkeland
Contributor III

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

0 项奖励
回复