ERR_VALUE writing using IntFlash on MK22FN512

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

ERR_VALUE writing using IntFlash on MK22FN512

跳至解决方案
755 次查看
hypernerd
Contributor I

I'm trying to use the Processor Expert IntFlash component to use a part of the program memory of the MK22FN512 as non-volatile storage.

 

Whenever I call any of the SetByteFlash, SetBlockFlash etc. I get the return value 3 (ERR_VALUE). Stepping through the code sees that this is caused by an Access error.

 

I understand that the Flash memory on the MK22F512 is in 2KB blocks, so I allocated a ROM/RAM Area in the CPU Component's Build Options at 0x7FC00, with size 0x400 and qualifier RWX. I also reduced the size of the m_text area by 0x400 from 0x7FBF0 to 0x7FBC0. I pass the address 0x7FC00 as the dest in the call to SetByteFlash or SetBlockFlash.

 

The corresponding calls to GetByteFlash and GetBlockFlash return with no error (ERR_OK) and it appears that the data read out is valid (all 0xFF as I can't write anything there).

 

I would appreciate any assistance.

 

Thanks,

 

Jamie

标签 (1)
0 项奖励
1 解答
515 次查看
priya_dwivedula
Contributor III

I had a similar issue when I was using MK22F512 but I was using SSD flash driver with KSDK1.2.0. I found that the problem was that the microcontroller was running in high speed run mode by default (HSRUN) and after some research, I figured out that I cannot write to flash in that mode.

Check out the following link to learn more about HSRUN mode:

http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4985.pdf

After I changed the clock to run in normal run mode, I was able to write to flash.

在原帖中查看解决方案

0 项奖励
3 回复数
515 次查看
marek_neuzil
NXP Employee
NXP Employee

Hello Jamie,

The issue can be also caused by protection settings of your flash memory. You can find these settings in the Component Inspector of the CPU component, Common Settings / Flash configuration field / Protection regions property group. See also the following screenshot:

pastedImage_3.png

Best Regards,

Marek Neuzil

0 项奖励
516 次查看
priya_dwivedula
Contributor III

I had a similar issue when I was using MK22F512 but I was using SSD flash driver with KSDK1.2.0. I found that the problem was that the microcontroller was running in high speed run mode by default (HSRUN) and after some research, I figured out that I cannot write to flash in that mode.

Check out the following link to learn more about HSRUN mode:

http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4985.pdf

After I changed the clock to run in normal run mode, I was able to write to flash.

0 项奖励
515 次查看
hypernerd
Contributor I

Thanks, this solved it. I had the Core clock at 120MHz, which forces HSRUN mode.

I created a second clock configuration with the Core clock at 80MHz (the limit before HSRUN is forced) and switch to that just before writing to Flash. I also had to set the IntFlash to be enabled in Low Speed mode.

0 项奖励