KE02Z EEPROM Initialization Example

File uploaded by Derek Snell Employee on Feb 3, 2016
Version 1Show Document
  • View in full screen mode

This is an example for the Kinetis KE02Z devices, showing how to program the

EEPROM with initial values when the flash is programmed.  The example works

on the FRDM-KE02Z40M board, and was written with Kinetis Design Studio (KDS)

v3.0.0.  The example also uses Processor Expert (PEx) to configure the UART

and erase/program the EEPROM.  The EEPROM programming works with the P&E

Micro Multilink Universal debugger, as well as the P&E Micro OpenSDA debugger

app for the FRDM-KE02Z40M board.

 

 

To program the EEPROM with initial values, the application declares constants

for the EEPROM locations, and initializes these in the source code in eeprom.c.

Compiler pragmas/attributes are used to force the linker to place these

constants in EEPROM, using the m_eeprom memory section defined in the linker

command file \Project_Settings\Linker_Files\ProcessorExpert.ld.  The P&E

Micro flash programming algorithms initialize the EEPROM in 4Byte words.

Therefore, any initialized EEPROM locations should be in aligned 4Byte words.

This example initializes the first 4Bytes in the EEPROM as 0, 64, 128, 192.

 

 

The example uses a terminal program to display EEPROM information.  It connects

to the OpenSDA COM port on the FRDM-KE02Z40M board using UART1 from the KE02Z.

The terminal settings are:

  Baud Rate: 38,400

  Data: 8bit

  Parity: None

  Stop: 1bit

  Flow Control: None

 

The example prints 5 bytes of EEPROM to the terminal after reset: the 4

initialized bytes, plus the following EEPROM byte which was not initialized.

Then the example increments the first byte, and decrements the second byte,

and writes the new values back to EEPROM.  The other 3 bytes are not changed.

Then the application prints the new EEPROM values of all 5 bytes.  Everytime

the MCU is reset, it will print the existing EEPROM data and then the changed

data.  Below is the example output from the terminal after initially

programming the KE02Z, and then doing a single reset:

 

 

Terminal output:

  KE02Z EEPROM example

  EEPROM values after reset = 0 64 128 192 255

  EEPROM values after updating = 1 63 128 192 255

  KE02Z EEPROM example

  EEPROM values after reset = 1 63 128 192 255

  EEPROM values after updating = 2 62 128 192 255

Attachments

Outcomes