Can't get flash erasing and writing on MK22FN128VLH10 to work

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

Can't get flash erasing and writing on MK22FN128VLH10 to work

ソリューションへジャンプ
961件の閲覧回数
rubenjonsson
Contributor II

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...

ラベル(1)
0 件の賞賛
返信
1 解決策
713件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ruben,

  Please check your core clock frequency. If you want to do the flash operation, you should make your MK22FN128VLH10 work at the RUN mode, then the core frequency can't exceed 72Mhz.

  You can find it in the reference manual.

The core and system clock frequencies must be 100 MHz or slower in HSRUN, 72MHz or slower in RUN.

  in  the HSRUN mode:Flash programming/erasing is not allowed, you can find this in the reference manual:K22P121M100SF9RM.pdf, page 343.

Wish it helps you!


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
713件の閲覧回数
rubenjonsson
Contributor II

Thanks, that was it.

0 件の賞賛
返信
714件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ruben,

  Please check your core clock frequency. If you want to do the flash operation, you should make your MK22FN128VLH10 work at the RUN mode, then the core frequency can't exceed 72Mhz.

  You can find it in the reference manual.

The core and system clock frequencies must be 100 MHz or slower in HSRUN, 72MHz or slower in RUN.

  in  the HSRUN mode:Flash programming/erasing is not allowed, you can find this in the reference manual:K22P121M100SF9RM.pdf, page 343.

Wish it helps you!


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信