FRDMK22 Flash Writing SDK example

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FRDMK22 Flash Writing SDK example

Jump to solution
866 Views
attiliorossi321
Contributor II

Has anyone tried the sdk example about flash writing ?

I mean the frdmk22f_pflash project with SDK 3.0.0

It works perfectly, but as soon as the clock it's chanched to the maximum frequency  using the  BOARD_BootClockHSRUN functions ( core & sistem t 120 mhz, busclock 60 mhz, flash clock 24 mhz) it fails the result and doesn't write the flash.

thanks in advance.

Attilio

 

0 Kudos
Reply
1 Solution
855 Views
ErichStyger
Specialist I

Hi @attiliorossi321 ,

As @myke_predko commented: unfortunately several devices of the K series cannot use flash programming if running above a certain speed. See https://community.nxp.com/thread/377633 

What I do is doing gear shifting (moving temporary to a lower speed and then back again). Be aware that this might affect other parts of your application (e.g. changing the clock speed might change your communication speed, even might break USB communication).

If you want to see how to do such a gear shifting, have a look at https://github.com/ErichStyger/MetaClockClock/blob/main/Firmware/ClockCommon/nvmc.c (that one shows it for different K devices, look for SMC_SetPowerModeRun()).

I hope this helps, and Happy New Year!

Erich

 

PS: the hardware which uses the above flash programming to save configuration data: New MetaClockClock V3 finished with 60 Clocks | MCU on Eclipse 

View solution in original post

0 Kudos
Reply
4 Replies
856 Views
ErichStyger
Specialist I

Hi @attiliorossi321 ,

As @myke_predko commented: unfortunately several devices of the K series cannot use flash programming if running above a certain speed. See https://community.nxp.com/thread/377633 

What I do is doing gear shifting (moving temporary to a lower speed and then back again). Be aware that this might affect other parts of your application (e.g. changing the clock speed might change your communication speed, even might break USB communication).

If you want to see how to do such a gear shifting, have a look at https://github.com/ErichStyger/MetaClockClock/blob/main/Firmware/ClockCommon/nvmc.c (that one shows it for different K devices, look for SMC_SetPowerModeRun()).

I hope this helps, and Happy New Year!

Erich

 

PS: the hardware which uses the above flash programming to save configuration data: New MetaClockClock V3 finished with 60 Clocks | MCU on Eclipse 

0 Kudos
Reply
807 Views
attiliorossi321
Contributor II

Many thanks Erich.

I'm going to have a look to the documentation. Altought I'm not agree to change clock.

Attilio

0 Kudos
Reply
863 Views
myke_predko
Senior Contributor III

@attiliorossi321 ,

The maximum clock speed you can write to the Flash in the MK22FN512VLH12 (that's in the FRDM-K22F) is 60Mhz.

This really caused me a lot of headaches because I was using the FRDM-K22F to develop code for my MK22FN1M0AVDM12 based product - the product's processor can write at 120MHz.  I ended up developing the code to run at 60MHz on the FRDM-K22F and ported it to the faster board.  

There have been discussions here on how you can run the FRDM-K22F but program the Flash at 60MHz but they are a bit out there and I felt to be more work and risk than getting my code working at the slower speed.  

The speeds at which different Kinetis parts can write to the Flash don't seem to follow any kind of logic - there is some documents on the website here (but I'll be damned if I can ever find them using the search function) - by doing some searching here on the Kinetis forum (and me whining) you can find links to them.  You can also find out the maximum speed by reading the specific part's Reference Manual (although I just scanned it and couldn't find it - NXP doesn't make it easy to find this information as it really should be front and centre for designers).  

Good luck, sorry I can't give you better news.  

0 Kudos
Reply
806 Views
attiliorossi321
Contributor II

Thanks  Mykepredkomimet for your reply.

I had headache too about this problem. Because I tried a lot of time.

Anyway I found a compromise. Now I'm running at 80 Mhz of system clock and 40 Mhz at busclock.

With a flash clock at 24 Mhz. Seem to work properly.

To be honest I need to flash the controller just in bootloader mode only. As I wrote to Erich I dislike to change the clock but, in this case, as soon as the bootloader has finished and the application starts I changhe it. I will make up my mind.

Grazie.

Attilio