How to read and write EEPROM KE02Z64 or FRDMKE02

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

How to read and write EEPROM KE02Z64 or FRDMKE02

1,551 Views
ad_d
Contributor I

Hello,

Trying to code Hourmeter.

I need help I am trying to store the data RTC clock hour data in EEPROM but struggling to read the data.

I am using RTC Task per sec and trying to record it trigger of every hour. I am able to display the seconds and hour data on run time.

But I am failing to store the data so Hourmeter data is getting reset at every power up.

I am using similar code as below sample code from EEPROM DEMO (FRDM-KE02Z40M\KEXX_DRIVERS_V1.2.1_DEVD) PAckage.

Please can someone help me to how to read the EEPROM and is wirting to EEPROM is correct way implemented

/* Erase 99th sector */

    for( i=0;i<128;i++)

    {

        EEPROM_EraseSector( i*2 + EEPROM_START_ADDRESS);

    }

   

    for(i=0;i<512;i++)

    {

        u8DataBuff[i] = (uint8_t)i;

    }

   

    /* write data to erased sector */

    EEPROM_Program( EEPROM_START_ADDRESS,&u8DataBuff[0],256 );

THanks!

AD

Labels (1)
0 Kudos
Reply
3 Replies

1,052 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Arti D,

      If you want to read the eeprom data, just do like this :

   for(ch =0;ch<16;ch++)
   {
       printf("0x%x,",*((uint8_t *)(i*16+ch+EEPROM_START_ADDRESS)));
  

}

You can read the address *((uint8_t *)(EEPROM_START_ADDRESS))) directly.

Wish it helps you!

If you still have question, please contact me!


Have a great day,
Jingjing

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

0 Kudos
Reply

1,052 Views
ad_d
Contributor I

HI Jingjing,

Thanks I saw exact saem code in sample code. I was trying to read 16 & 32 bytes at same time learned that only 8 bytes can be read at a time.

Does this EEPROM retain data after power cycle. In my case the memory location data is getting reset back to 0xFF.

Any ideas.

0 Kudos
Reply

1,052 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Arti D,

     You said "trying to read 16 & 32 bytes at same time ", how did you realize it? Use the for, or other code? Please give me your read code.

  Of course EEPROM retain data after power cycle, if you don't do erase it.

  Do you mean every time when you power off, then power on, the eeprom data all reset back to 0XFF, did you download the data again?

The EEPROM address range is : 0X10000000-0X100000FF, did you write the correct place?

Regards,

Jingjing

0 Kudos
Reply