Minimum Code for K22FX EEPROM initialization

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

Minimum Code for K22FX EEPROM initialization

Jump to solution
744 Views
randyhermes
Contributor III

I am working with the C90TFS driver to initialize the EEPROM settings on a K22FX processor.

It looks like I can use DEFlashPartition() to accomplish this, but the documentation isn't clear what should be passed in for the pFlashCommandSequence parameter.

Does anyone have example code or advice on what to do?

 

Also - I understand that this should only be done once so I plan on using the following logic

     Get Current EEPROM config

     If EEPROM not initialized

          Initialize EEPROM

 

Thank You

Randy Hermes

Labels (1)
0 Kudos
1 Solution
507 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Randy:

In general launching a flash command involves 3 steps:

1- Filling the FCCOBx registers with the required parameters.

2- Clearing the CCIF flag to trigger the command.

3- Waiting for CCIF to be set again, indicating the command completion.

The C90TFS abstracts all of that from the user, but in particular the steps (2) and (3) are in the FlashCommandSequence function. The code of that function needs to be executed from RAM in most cases, that's where RelocateFunction() copies or clones the function to a space in RAM and returns a pointer to the copied function in RAM. That is the pointer you have to use as a parameter in the APIs. You can see all of this in the code I pasted to my first response.

I hope this is not very confusing.

Regards!

Jorge Gonzalez

View solution in original post

0 Kudos
4 Replies
507 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Randy Hermes:

Attached there are 3 files I took from the C90TFS standalone installation (not the one that comes with KSDK). Those files are an example for the K21FX512xxx10. The example demonstrates several uses of the Flash driver (erase, program, checksum, read resource, etc) but you may use the FlexNVM part and refer to the use of DEFlashPartition().

The code will respond to your questions as next:

- The parameter pFlashCommandSequence is a function pointer. In the example the pointer used is called g_FlashLaunchCommand and it's the result of calling RelocateFunction().

- The partition should only be done once. In the example project there is a check for partition as next:

if (0x0U == flashSSDConfig.EEEBlockSize)

{

...

Also for your reference there is a user manual for the C90TFS driver in KSDK installation:

C:\Freescale\KSDK_1.2.0\platform\drivers\src\flash\C90TFS\FSL_eNVM_FTFx_UM.pdf

I hope this helps. Let me know if you have any questions.


Regards!,
Jorge Gonzalez

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

0 Kudos
507 Views
randyhermes
Contributor III

Thank you Jorge,

I actually have something working now.  The code is

EEPROM.png

This works fine, will only set the partition once and using the C90TFS FlashCommandSequence seems to work fine.

It would still be nice to have a better description of what pFlashCommandSequence is supposed to do.

Thanks again

Randy

0 Kudos
508 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Randy:

In general launching a flash command involves 3 steps:

1- Filling the FCCOBx registers with the required parameters.

2- Clearing the CCIF flag to trigger the command.

3- Waiting for CCIF to be set again, indicating the command completion.

The C90TFS abstracts all of that from the user, but in particular the steps (2) and (3) are in the FlashCommandSequence function. The code of that function needs to be executed from RAM in most cases, that's where RelocateFunction() copies or clones the function to a space in RAM and returns a pointer to the copied function in RAM. That is the pointer you have to use as a parameter in the APIs. You can see all of this in the code I pasted to my first response.

I hope this is not very confusing.

Regards!

Jorge Gonzalez

0 Kudos
507 Views
randyhermes
Contributor III

Thanks again Jorge,

You actually cleared this up for me, now I understand what the pFlashCommandSequence param is for.

It would be nice if this explanation made it into the rev of the C90TFS doc.

This will also save me some frustration if I ending using the drivers for writes to FLASH.

Take care

Randy

0 Kudos