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 I2C Example with other methods

Overview

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

Supported Platforms

These Freescale Freedom development platforms and Tower System modules are supported by the FlexIO I2C example.

System Requirement

Hardware requirements

Toolchain requirements

Software requirements

Getting Started

Hardware settings

This example requires connecting the FlexIO pins with the I2C1 pins. Connect FlexIO pins to the I2C1 pins. Note that the default uses FlexIO pin2 and pin4:

FlexIO Pins Connects To I2C1 Pins
FlexIO Pin2 -> I2C1 SDA
FlexIO Pin4 -> I2C1 SCL

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

TWR-KL43Z48

FlexIO Pins Connects To I2C1 Pins
Pin Name Board Location Pin Name Board Location
PTD2/FLEXIO_PIN2 Primary Elevator B45 -> I2C1 SDA Primary Elevator A8
PTD4/FLEXIO_PIN4 Primary Elevator B59 -> I2C1 SCL Primary Elevator A7

FRDM-KL43Z48M

FlexIO Pins Connects To I2C1 Pins
Pin Name Board Location Pin Name Board Location
PTD2/FLEXIO_PIN2 J2-4 -> I2C1 SDA J2-18
PTD4/FLEXIO_PIN4 J2-6 -> I2C1 SCL J2-20

FRDM-KL27Z48M

FlexIO Pins Connects To I2C1 Pins
Pin Name Board Location Pin Name Board Location
PTD2/FLEXIO_PIN2 J1-5 -> I2C1 SDA J2-18
PTD4/FLEXIO_PIN4 J1-9 -> I2C1 SCL J2-20

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

These instructions are displayed/shown on the terminal window:

++++++++++++++++ FLEXIO I2C Master Send/Receive Example Start +++++++++++++++++
-------------------Non-blocking&Blocking example--------------------------
1. FlexIO simulated I2C master write a buffer to I2C1
2. I2C1 acts as slave and receives data from FlexIO simulated I2C Master.
3. Compare rxBuff and txBuff to see result.
4. FlexIO simulated I2C master read a buffer from I2C1
5. I2C1 send the buffer and FlexIO simulated I2C master receives the buffer.
6. Compare rxBuff and txBuff to see result.
============================================================
Press any key to start transfer:

Type a character on the keyboard and the FlexIO simulated I2C sends a buffer to the I2C1. It also compares the received buffer on the I2C1 side with the txBuff and checks whether the result is successful. Then, the I2C1 sends a buffer to the FlexIO simulated I2C, compares the receive buffer in the FlexIO simulated I2C side to the txBuff, and checks whether the result is successful.

----------Non-blocking example----------
FlexIO simulated I2C master to I2C standard slave write transfer succeed!!
FlexIO simulated I2C master to I2C standard slave read transfer succeed!!
------------Blocking example------------
FlexIO simulated I2C master to I2C standard slave write transfer succeed!!
FlexIO simulated I2C master to I2C standard slave read transfer succeed!!
...