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
FlexIO simulated SPI Example with other methods

Overview

The FlexIO SPI example application demonstrates the FlexIO simulated SPI driver working with different methods. The FlexIO SPI example shows the transmit/receive between the FlexIO-simulated SPI and SPI1 using these methods:

master

Supported Platforms

This Tower System module is supported by the FlexIO SPI example:

System Requirement

Hardware requirements

Toolchain requirements

Software requirements

Getting Started

Hardware settings

This example requires connecting FlexIO pins with the SPI1 pins. Connect FlexIO pins to the SPI1 pins. Note that the default uses the FlexIO pin0~pin3:

FlexIO Pins Connects To SPI1 Pins
FlexIO Pin0 -> SPI1 MOSI/MISO
FlexIO Pin1 -> SPI1 MISO/MOSI
FlexIO Pin2 -> SPI1 SCK
FlexIO Pin3 -> SPI1 CSn

Make these connections between the FlexIO Pins and the SPI1 pins by using external wires:

master example

FlexIO Pins Connects To SPI1 Pins
Pin Name Board Location Pin Name Board Location
PTD0/FLEXIO_PIN0 Primary Elevator B46 -> SPI1 MOSI Primary Elevator B10
PTD1/FLEXIO_PIN1 Primary Elevator B48 -> SPI1 MISO Primary Elevator B11
PTD2/FLEXIO_PIN2 Primary Elevator B45 -> SPI1 SCK Primary Elevator B7
PTD3/FLEXIO_PIN3 Primary Elevator B44 -> SPI1 CSn Primary Elevator B9

FRDM-KL27Z48M

FlexIO Pins Connects To SPI1 Pins
Pin Name Board Location Pin Name Board Location
PTD0/FLEXIO_PIN0 J1-1 -> SPI1 MOSI J2-18
PTD1/FLEXIO_PIN1 J1-3 -> SPI1 MISO J2-20
PTD2/FLEXIO_PIN2 J1-5 -> SPI1 SCK J1-11
PTD3/FLEXIO_PIN3 J1-7 -> SPI1 CSn J1-9

slave example

FlexIO Pins Connects To SPI1 Pins
Pin Name Board Location Pin Name Board Location
PTD0/FLEXIO_PIN0 Primary Elevator B46 -> SPI1 MISO Primary Elevator B11
PTD4/FLEXIO_PIN1 Primary Elevator B48 -> SPI1 MOSI Primary Elevator B10
PTD2/FLEXIO_PIN2 Primary Elevator B45 -> SPI1 SCK Primary Elevator B7
PTD4/FLEXIO_PIN3 Primary Elevator B44 -> SPI1 CSn Primary Elevator B9

FRDM-KL27Z48M

FlexIO Pins Connects To SPI1 Pins
Pin Name Board Location Pin Name Board Location
PTD0/FLEXIO_PIN0 J1-1 -> SPI1 MOSI J2-20
PTD1/FLEXIO_PIN1 J1-3 -> SPI1 MISO J2-18
PTD2/FLEXIO_PIN2 J1-5 -> SPI1 SCK J1-11
PTD3/FLEXIO_PIN3 J1-7 -> SPI1 CSn J1-9

Prepare the example

  1. Connect a USB cable between the PC host and the OpenSDA USB port on the board.
  2. For TWR-KL43Z48M, insert TWR board into TWR-ELEV.
  3. Open a serial terminal with these settings:
    • 115200 baud rate
    • 8 data bits
    • No parity
    • One stop bit
    • No flow control
  4. Download the program to the target board.
  5. Either press the reset button on your board or launch the debugger in your IDE to begin running the example.

Run the example

master example

These instructions are displayed/shown on the terminal window:

++++++++++++++++ FLEXIO SPI Send/Receive Example Start +++++++++++++++++
1. FlexIO-simulated SPI master starts transfer with the masterWriteBuff and masterReadBuff.
2. SPI1 acts as slave also transfer with the slaveWriteBuff and slaveReadBuff.
3. Compare the masterWriteBuff and the slaveReadBuff and the slaveWriteBuff and the masterReadBuff to see results.
============================================================
Press any key to start the transfer:

Type a character on the keyboard and the FlexIO-simulated SPI master starts the transfer with the SPI1 slave, compares the masterWriteBuff and slaveReadBuff, the slaveWriteBuff and the masterReadBuff to check whether the transfer is successful.

FlexIO simulated SPI master to SPI slave bidirectional transfer succeed!!
FlexIO simulated SPI master to SPI slave transfer DMA bidirectional transfer succeed!!
FlexIO simulated SPI master to SPI slave bidirectional transfer succeed!!
FlexIO simulated SPI master to SPI slave transfer DMA bidirectional transfer succeed!!
FlexIO simulated SPI master to SPI slave bidirectional transfer succeed!!
FlexIO simulated SPI master to SPI slave transfer DMA bidirectional transfer succeed!!
FlexIO simulated SPI master to SPI slave bidirectional transfer succeed!!
...

slave example

These instructions are displayed/shown on the terminal window:

++++++++++++++++ FLEXIO SPI Send/Receive Example Start +++++++++++++++++
1. SPI1 acts as master starts transfer with masterWriteBuff and masterReadBuff.
2. FlexIO simulated SPI slave also transfer with slaveWriteBuff and slaveReadBuff.
3. Compare masterWriteBuff and slaveReadBuff, slaveWriteBuff and masterReadBuff to see result.
============================================================
Press any key to start transfer:

Type a character on the keyboard and the SPI1 master starts the transfer with the FlexIO- simulated SPI slave, compares the masterWriteBuff and the slaveReadBuff, the slaveWriteBuff and the masterReadBuff to check whether the transfer is successful.

SPI master to FlexIO simulated SPI slave bidirectional transfer succeed!!
SPI master to FlexIO simulated SPI slave DMA bidirectional transfer succeed!!
SPI master to FlexIO simulated SPI slave bidirectional transfer succeed!!
SPI master to FlexIO simulated SPI slave DMA bidirectional transfer succeed!!
SPI master to FlexIO simulated SPI slave bidirectional transfer succeed!!
SPI master to FlexIO simulated SPI slave DMA bidirectional transfer succeed!!
...