EEPROM Emulation driver for KEA128 Demo Interpretation

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

EEPROM Emulation driver for KEA128 Demo Interpretation

EEPROM Emulation driver for KEA128 Demo Interpretation

[EEPROM emulation driver for KEA128 and KEA8] software used for Kinetis EA family product (without integrated EEPROM memory), which using the sector-erasable Flash memory be used to emulate the EEPROM through EEPROM emulation software.  The software could downloaded from here:

This document will interpret EEPROM emulation driver demo for KEA128 product and shows how the EEPROM emulation driver works and related API function introduction.

1> EEPROM emulation driver feature

The EEPROM emulation driver for SGF/FTM flash family implements the fix-length data record scheme. Several sectors shall be involved in emulation with a round robin scheduling scheme. The EEPROM functionalities to be emulated include initializing, de-initializing, reading, writing records.

The EEPROM emulation driver is more complicated than general Flash program data application with following features:

  • User configurable emulated EEPROM size.
  • Larger life for the flash memory used for EEPROM emulation.
  • Unique feature of Cache Table which makes data retrieval fast.
  • Support fix length record scheme only.
  • Support synchronous model which can be run from both RAM and FLASH. When running from FLASH, user needs to relocate flash launch command routine to RAM to avoid Read While Write error.
  • If any operation fails during EEPROM emulation, the driver will try to repeat that operation until successfully for several times (which is defined by user). If that operation still fails, the driver will make the related sector to DEAD to eliminate it from round robin sequence and continue other tasks without stopping driver.
  • Concurrency support via callback.
  • Release in C source code format.
  • Ready-to-use demos illustrating the usage of the driver with different compilers.

2> Demo interpretation

The demo routine located at default installation path: ..\\KEA EEPROM Emulation Driver\KEA_SGF180\Demos\build\TRK_KEAZ128\iar\Normal_demo folder.

For the demo runs in Flash memory, avoiding Read While Write error happened,

Eed_FlashLauchnCommand and g_EECallBack must be relocated to or placed in RAM when the main routine start. Then it will disable the cache and initialize Flash clock(KEA128 ICS module default clock mode is FEI, the default system/core clock is 21MHz, the Flash clock divider value set to 20 to make Flash clock to be 1MHz).

  After flash clock initialized, it will initialize EEPROM configuration start address. The status of each sector with five value, which means Blanked, Alternative, Active, Dead and Invalid.

The EE_ALLOTED_SECTORS macro will calculate the total number of sectors, which includes Active sectors and Alternative sectors.

#define EE_ALLOTED_SECTORS              (EE_ACTIVE_SECTORS + EE_READY_SECTORS)

The EE_ACTIVE_SECTORS value is 1 and EE_READY_SECTORS value is 2, so the EE_ALLOTED_SECTORS value is 3.

Then there with three allotted sector, and allocated at below address:

     eepromConfig.startSecAddr[0] = 0x1A00;

     eepromConfig.startSecAddr[1] = 0x1C00;

     eepromConfig.startSecAddr[2] = 0x1E00;

After initialize start address for EEPROM configuration, following to call Eed_DeinitEeprom() function to erase all sectors used for emulation.

Then it will initialize EEPROM emulation, includes to remove dead sector from EEPROM system and determine maximum valid index in array of start sector address after that; also includes initialize all sectors by erasing the “possible-error-sector”; and initialize and update cache table if enabled. It call Eed_InitAllSectors() function to initialize all sectors and allocate the current active sector to base sector. The Eed_ShiftIdxToBase() function will be called to shift the current index to base index of 0. After that, the EEPROM configuration startSecAddr array will change to :

     eepromConfig.startSecAddr[0] = 0x1E00;

     eepromConfig.startSecAddr[1] = 0x1A00;

     eepromConfig.startSecAddr[2] = 0x1C00;

The active sector start address at 0x1E00.

Then it will program erase cycle value to each sector start address, the erase cycle value will occupy 4 bytes with sector start address offset 0:

erase cycle value 0x1a00.png

Then make the base sector to be active and program the active indicator at sector start address offset 8. Here the base sector start address is 0x1E00, the active indicator will be programmed at 0x1E08 with active indicator value 0x55555555:

active indicator value 0x1e08.png

Then it will call Eed_SearchBlankSpace () function to find blank space of EEPROM system, in this demo, the blank space start address at 0x1e0c.

If enable the Flash cache, the cache will be cleared and updated during EEPROM emulation initialize phase.

The demo will write eight group data to EEPROM system, each group with 16 bytes data, total data number is 128 bytes. The data located at Flash start address is 0x1e0c. After each group data programming, it will following with the data ID info and program the status.

write data analyze.png

With all data was written, the all 128 bytes data was programed at 0x1e00 start EEPROM sector.

write data result.png

When the write data exceed the active EEPROM sector, the swapping will occur. The swapped EEPROM sector will record previous data and current write data. If there exist sector erase action, it will also update the erase cycle value.

The data is full and the new data written will make swap happens:

before swap 01_3rd.png

After swap happens:

swap start 01_3rd.png

At the end of demo, it will read EEPROM data back and make sure all valid record ID are written to EEPROM emulation.

Labels (1)
Comments

Hi Hui,

Thanks for this great help on EEPROM implementation on KEA128 controller. Actually I want to know can this thing be implemented in Keil, since I am using Keil uVision v5 for programming the kea128 board using OpenSDA programmer. 

Is there a way to it. The package which u have included in the above link contains examples for  Code Warrior and IAR workbench. I am unable to understand how the API of this can be used in a project, especially in Keil. How the package is integrated in the project??

Any help on this will be appreciated.!!!!

Hi

The KEA EEPROM Emulation driver doesn't call the library file, which provides the EEPROM Emulation driver source code.

Please refer below picture about the demo software architecture (IAR):

pastedImage_1.png

pastedImage_2.png

So, customer can port related EEPROM Emulation driver to Keil project.


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

I've tried to use the library both in Keil and in IAR. In both cases the MC (KEAZ128) restarts on the line 90:

p_FLashLanchComamnd(p_gEECallBack); 

of the file ee_low_level.c

I have the default ee_user_config.h

Any help is appreciated.

Hello bmwhui, constantinesafronov

I know this thread is very old.But need your help

Currently I am developing EEPROM Emulation software and I saw your link which (i.e. you have already developed) which meets our requirement. I downloaded the package mentioned in your post. But I am not able to compile your software under IAR as well as CW IDE.

When i am trying to build package in IAR getting below error.

pastedImage_3.png

Kindly help...Looking forward to hear from you.

Thanks

Sanyam Agarwal

Hi

The original project is complete testing with CodeWarrior v10.6 and IAR6.70 on SKEAZN8 and SKEAZ128 devices.

For you are using IAR V8.x, please check with IAR company if there need to install IDE software package to support old version IAR project.

Thank you.

best regards,

Mike

Hello, 

I'm new in using CodeWarrior, I downloaded the driver but have some problems adding it to Codewarrior.

I managed too import the Labs and flash them. Should I just some files from the demo to a lab?

Thank you in advance!!

Hello Catalin,

Could you post your question at CodeWarrior for MCU community?

Thanks for the understanding.

best regards,

Mike

No ratings
Version history
Last update:
‎10-07-2015 04:36 AM
Updated by: