Problems using internal flash in MK22F

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Problems using internal flash in MK22F

ソリューションへジャンプ
543件の閲覧回数
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 解決策
414件の閲覧回数
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 返信
415件の閲覧回数
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 件の賞賛