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

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

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

跳至解决方案
960 次查看
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 解答
712 次查看
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 回复数
712 次查看
rubenjonsson
Contributor II

Thanks, that was it.

0 项奖励
回复
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 项奖励
回复