How to use "fsl_flash" componect of Processor Expert

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

How to use "fsl_flash" componect of Processor Expert

3,015 Views
tangwang
Contributor I

Hi,

 

I use KDS 2.0.0 + KSDK 1.1.0 and enable Processor Expert to develop FRDM-K22F.

How to fill the parameter in PE Component Inspector?

 

21197_21197.png1.png

 

And how to use API to read/write internal flash?

Thanks!

Labels (1)
Tags (2)
0 Kudos
8 Replies

1,401 Views
ivadorazinova
NXP Employee
NXP Employee

Hello Tang wang,


you need to know (from linker file or the manual) where at the address the area of the flash memory starts and its size and these values you fill to properties in flash component.

I recommend you to go to folder of KSDK, e.g. C:\Freescale\KSDK_1.1.0\platform\drivers\src\flash\C90TFS

and here you have a user manual for Standard Software Driver for C90TFS/FTFx Flash.

I hope it helps you,

Iva

0 Kudos

1,401 Views
tangwang
Contributor I

Anybody help me ?

0 Kudos

1,401 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Tang Wang:

Attached you can find a very simple KSDK + Processor Expert project showing how to configure and use the fsl_flash component with a K22FN512 as the one in FRDM-K22F board. The demo project simply writes 16 x 32-bit values from a buffer to flash memory starting at address 0x40000.

As you were advised by colleague Iva, the fsl_flash component settings depend on the specific device, so for each case you need to visit the Reference Manual to see the corresponding addresses and sizes.

I hope this helps.


Regards!,
Jorge Gonzalez

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

0 Kudos

1,401 Views
GR8geek
Contributor II

Hi Jorge,

I tried your code on FRDM-K82F target, with my KDS PEx based project, and it is not working. When I call:

readError = FlashProgram(&flash1_InitConfig0, (uint32_t)(pAddress + 4*i), 0x4, (uint8_t*)&myData[i], \ FlashCommandSequence);

I get readError = 0x0020. Which corresponds to FTFx_ERR_ACCERR. I have disabled global interrupts during the call but can't get around the issue.

My another question is that how do fsl_flash component methods get around flash read-while-write issue? Do the component methods automatically handle relocation into RAM? What am I missing?

Thanks,

-Irwin

0 Kudos

1,401 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hi Irwin,

Please consider the next points about the flash driver:

- In the fsl_os_abstraction component select None as the used timer. By default SysTick is selected.

- The K82F must not be in HSRUN mode (e.g. 150 MHz). Flash commands are not allowed when in HSRUN mode.

- The FlashCommandSequence() must indeed be relocated to RAM by calling RelocateFunction (I actually missed this step in my previous example). Then use the returned pointer as parameter for the flash APIs. Take a look at the attached source file.

These hints should resolve your issue.

Regards!

Jorge Gonzalez

0 Kudos

1,401 Views
Tonkabot
Contributor III

Hi Jorge,

   I am using the MK22FN512xxx12 part, and I am running it at 120Mhz.

I have tried to use the PEX components (the intFlash kinetis component) to program my calibration data into a single 2k page, but I get nothing but errors.    I see here that you say The K82 cannot be flash programmed in HSRUN mode (150Mhz),  and I suspect that this might also be my problem.  I can't find where the reference manual says anything about there being a max speed.  I am running in PEE MCG mode with a 120Mhz core, 60Mhz bus, and 24Mhz Flash clock  (which sounds okay to me)

    So do I need to set up another clock to use or something on my K22 also?    

I also have downloaded the KSDK 2.2 for my CPU and was going to try just dumping the two files fsl_flash .c and .h into my code and not use the PEX component - will that be any better/different?

Brynn

0 Kudos

1,401 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Brynn Rogers,

Indeed, flash programming is not allowed in HSRUN mode. This is mentioned in the K22FN512xxx12 Reference Manual:

pastedImage_2.png

As workaround you can have a clock configuration for max speed (120 MHz in HSRUN) and another for RUN mode (80 MHz). Change to the 80 MHz clock configuration when writing to flash and then back to 120 MHz.

See below some posts about clock configurations in KSDK v1.x:

KSDK Clock configurations and Low Power modes with Processor Expert 

Change between clock configurations 

https://community.nxp.com/thread/356449 

If you are in an early development stage, I would highly recommend you to use instead the latest KSDK v2.x. Adding only the files fsl_flash.c / fsl_flash.h might not be direct since there are a few file dependencies.

Regards!

Jorge Gonzalez

0 Kudos

1,401 Views
Tonkabot
Contributor III

Thanks, Jorge,

    It would be really really helpful to anyone who is trying to write to flash that has not memorized the reference manual that it would mention this in chapter 29, the Flash Memory module (FTFA) portion of the Reference manual.

  Or if the error message number returned by the PEX code (or fsl_flash.c code) would come right out and say that the clock is too high....

Everything I am doing is using the PEX and especially Erich Styger's excellent custom PEX components.   

Brynn

0 Kudos