Kinetis SDK v.1.2 Demo Applications User's Guide  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Flash Demo

This demo application demonstrates how to use the Flash drivers.

Overview

The Flash demo project shows how to erase, program, and perform swap (if available) on the Flash module.

Note:

  1. Target exists for Flash memory space. Since the demo will operate with two last sectors of lower half and the whole upper half of Program flash memory of the platforms with SWAP feature; six last sector of Program flash of the platforms without SWAP feature, the user should NOT store any program code or data in the above locations.

  2. The flash swap demo will be failed if the tested board has already run swap command with swap indicator address different from the value defined in demo. To overcome the issue, erase all chip to un-initialize the swap system and re-run the demo.
    features include:
  3. Read to non-volatile information memory region
  4. Flash Erase by block or sector, including margin read options
  5. Programming region defined by user
  6. Flash verify support
  7. Flash Swap (if supported on device)

  8. To ensure that other demos won't be affected, user need to erase all chip to ensure the successful execution of next demos.

Supported Platforms

These Freescale Freedom development platforms and Tower System modules are supported by the KSDK Flash demo.

Platforms with SWAP feature:

Platforms without SWAP feature:

System Requirement

Hardware requirements

Toolchain requirements

Software requirements

Getting Started

The Flash Demo example code shows how to erase and program the Flash content and use the swap feature if it is supported on the device.

Prepare the Demo

  1. Connect a USB cable between the PC host and the OpenSDA USB port on the board.
  2. Open a serial terminal with these settings:
    • 115200 (9600 for FRDM-KL03Z48M) for baud rate
    • 8 data bits
    • No parity
    • One stop bit
    • No flow control
  3. Download the program to the target board.
  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

For more detailed instructions, see a Kinetis SDK User's Guide for your board.

Commands/Directions

  1. Select the Debug target from within the IDE and build the project selected for the target hardware. The default Debug target runs from flash and demonstrates the Swap feature for devices that support Swap (e.g., TWR-K64F120M).
  2. Connect one end of the USB cable to a PC host and the other end to the OpenSDA connector on the board.
  3. Open Terminal program such as TeraTerm, Putty, or Hyperterminal.
  4. Configure the Terminal program to select the OpenSDA COMx port for the board using
    • 115200 8N1: 115200 baud, 8 data bits, No parity, 1 Stop bit.
    • Or FRDM-KL03Z48M 9600 8N1: 9600 baud, 8 data bits, No parity, 1 Stop bit.
  5. Connect to the board with the debugger (download & debug), run the program, and view the Terminal messages for Flash operations being performed.
  6. For devices that support Swap, the Flash_Debug target copies (programs) the application that is running from the lower half to the upper half and then issues swap commands.
  7. Flash memory blocks are swapped at the next reset. Disconnect debug session and hit the reset button on the board. Note: During swap, some memory locations depending on program flash size (e.g., for TWR-K64F120M: 0x7F100 & 0xFF100) are swapped and displayed on the terminal showing how the memory map changes.
  8. For devices that do not support swap, view the terminal messages for Flash operations that are occurring for the demo.
  9. Terminal displays the message "Flash Demo Complete!" when finished.

    Note: Callback functions are not currently supported during flash erase or program operations

    Note: For K22F and KV31, Flash erase and program operations are not allowed in High-Speed RUN modes. Therefore, the core clock speed is restricted to 80 MHz or less.