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
I2C Demo with RTOS

This demo application demonstrates the I2C demo on different RTOS.

Overview

This I2C application demonstrates the SDK Peripheral drivers working on different RTOS. The application acts as both the I2C master and the slave device on different I2C buses, such as the I2C Master on the I2C0 bus and the I2C Slave on the I2C1 bus. It can run on a single board or on two different boards. When connecting the two I2C buses on one board, the master sends the command using the I2C0 bus to the slave using the I2C1 bus. When connecting the I2C0 bus to the I2C1 bus on the other board, the application running on the first board is a master and sends a command to the other board which acts as a slave. This means that the first board can send a command and get a response from the other board by using the I2C bus.

The basic purpose of this demo is:

  1. Read the Kinetis chip UID (low 32bits) from the slave board
  2. Read the Kinetis chip internal temperature from the slave board
  3. Control the RED/GREEN/BLUE color LEDs on the slave board

The application creates three different tasks to handle events concurrently:

  1. Master task: responds to the user interface interaction, runs as a I2C master, and acts as a simple UI. It accepts user's commands to read the basic chip UID, chip temperature and control the on board LED, and power mode on the slave.
  2. Slave task: responds to the command received from the I2C master and returns the result to the master.
  3. ADC sample task: responds to getting the chip temperature in a period.
  4. For the bare metal version, the master and slave tasks are separated into two separate projects.

Supported RTOS

Supported Platforms

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

The Bare Metal (no RTOS) demo Supported Platforms:

The FreeRTOS, µC/OS-II, µC/OS-III demo Supported Platforms:

The MQX demo Supported Platforms:

System Requirement

Hardware requirements

Toolchain requirements

Software requirements

Getting Started

The I2C RTOS application is designed to work on one single board or two different boards. Note that the bare-metal version only supports two boards.

Build with different RTOS support

Before running this application, build it with the RTOS you want to use. The projects for different RTOSes are differentiated by the workspace file name in the format of i2c_rtos_<rtos>.eww. For example, in IAR, the i2c_rtos_ucosii.eww workspace file is the µC/OS-II version of this application. After opening the appropriate workspace, build the ksdk_<rtos>_lib project and build the application project. A binary named i2c_rtos_<rtos>.out is generated.

Hardware configuration

Make the connections between the listed signals by using the external wires.

Freescale Freedom FRDM-K22F

FRDM-K22F Single Board
Master Connects To Slave
Pin Name Board Location Pin Name Board Location
I2C0_SCL J24 - Pin 12 -> I2C1_SCL J1 - Pin 13
I2C0_SDA J24 - Pin 10 -> I2C1_SDA J2 - Pin 7


FRDM-K22F Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
I2C0_SCL J24 - Pin 12 -> I2C1_SCL J1 - Pin 13
I2C0_SDA J24 - Pin 10 -> I2C1_SDA J2 - Pin 7
GND TP21 -> GND TP21

Freescale Freedom FRDM-K64F

FRDM-K64F Single Board
Master Connects To Slave
Pin Name Board Location Pin Name Board Location
I2C0_SCL J2 - Pin 20 -> I2C1_SCL J4 - Pin 12
I2C0_SDA J2 - Pin 18 -> I2C1_SDA J4 - Pin 10


FRDM-K64F Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
I2C0_SCL J2 - Pin 20 -> I2C1_SCL J4 - Pin 12
I2C0_SDA J2 - Pin 18 -> I2C1_SDA J4 - Pin 10
GND J2 - Pin 14 -> GND J2 - Pin 14

Freescale Freedom FRDM-KL02Z


FRDM-KL02Z Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
I2C0_SCL J7 Pin 10 -> I2C0_SCL J7 Pin 10
I2C0_SDA J7 Pin 9 -> I2C0_SDA J7 Pin 9
GND J7 Pin 7 -> GND J7 Pin 7

Freescale Freedom FRDM-KL25Z

FRDM-KL25Z Single Board
Master Connects To Slave
Pin Name Board Location Pin Name Board Location
I2C0_SCL J10 - Pin 6 -> I2C1_SCL J10 - Pin 12
I2C0_SDA J10 - Pin 8 -> I2C1_SDA J10 - Pin 10


FRDM-KL25Z Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
I2C0_SCL J10 Pin 6 -> I2C1_SCL J10 Pin 12
I2C0_SDA J10 Pin 8 -> I2C1_SDA J10 Pin 10
GND J9 Pin 14 -> GND J9 Pin 14

Freescale Freedom FRDM-KL26Z

FRDM-KL26Z Single Board
Master Connects To Slave
Pin Name Board Location Pin Name Board Location
I2C0_SCL J4 - Pin 6 -> I2C1_SCL J2 - Pin 20
I2C0_SDA J4 - Pin 8 -> I2C1_SDA J2 - Pin 18


FRDM-KL26Z Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
I2C0_SCL J4 - Pin 6 -> I2C1_SCL J2 - Pin 20
I2C0_SDA J4 - Pin 8 -> I2C1_SDA J2 - Pin 18
GND J2 - Pin 14 -> GND J2 - Pin 14

Freescale Freedom FRDM-KL27Z

FRDM-KL27Z Single Board
Master Connects To Slave
Pin Name Board Location Pin Name Board Location
I2C0_SCL J4 Pin 20 -> I2C1_SCL J4 Pin 12
I2C0_SDA J4 Pin 18 -> I2C1_SDA J4 Pin 10


FRDM-KL27Z Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
I2C0_SCL J4 Pin 20 -> I2C1_SCL J4 Pin 12
I2C0_SDA J4 Pin 18 -> I2C1_SDA J4 Pin 10
GND J2 Pin 14 -> GND J2 Pin 14

Freescale Freedom FRDM-KL43Z

FRDM-KL43Z Single Board
Master Connects To Slave
Pin Name Board Location Pin Name Board Location
I2C0_SCL J4 Pin 2 -> I2C1_SCL J2 Pin 20
I2C0_SDA J4 Pin 4 -> I2C1_SDA J2 Pin 18


FRDM-KL43Z Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
I2C0_SCL J4 Pin 2 -> I2C1_SCL J2 Pin 20
I2C0_SDA J4 Pin 4 -> I2C1_SDA J2 Pin 18
GND J2 Pin 14 -> GND J2 Pin 14

Freescale Freedom FRDM-KL46Z

FRDM-KL46Z Single Board
Master Connects To Slave
Pin Name Board Location Pin Name Board Location
I2C0_SCL J4 Pin 6 -> I2C1_SCL J2 Pin 20
I2C0_SDA J4 Pin 8 -> I2C1_SDA J2 Pin 18


FRDM-KL46Z Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
I2C0_SCL J4 Pin 6 -> I2C1_SCL J2 Pin 20
I2C0_SDA J4 Pin 8 -> I2C1_SDA J2 Pin 18
GND J2 Pin 14 -> GND J2 Pin 14

Freescale Modular Reference Board MRB-KW01

MRB board doesn't include user controllable LEDs, so the only available commands are: 4 (Read Temperature) and 5 (Read Id).

MRB-KW01 Single Board
Master Connects To Slave
Pin Name Board Location Pin Name Board Location
I2C0_SCL J15 - Pin 12 -> I2C1_SCL J14 - Pin 14
I2C0_SDA J14 - Pin 8 -> I2C1_SDA J14 - Pin 12


MRB-KW01 Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
I2C0_SCL J15 - Pin 12 -> I2C1_SCL J14 - Pin 14
I2C0_SDA J14 - Pin 8 -> I2C1_SDA J14 - Pin 12
GND J14 - Pin 18 -> GND J14 - Pin 18

TWR-K21D50M Tower System module

TWR-K21D50M Single Board
Master Connects To Slave
Pin Name Board Location Pin Name Board Location
PTC10/I2C0_SCL Primary Elevator - Pin A7 -> PTD2/I2C1_SCL Primary Elevator - Pin B45
PTC11/I2C0_SDA Primary Elevator - Pin A8 -> PTD3/I2C1_SDA Primary Elevator - Pin B44


TWR-K21D50M Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
PTC10/I2C0_SCL Primary Elevator - Pin A7 -> PTD2/I2C1_SCL Primary Elevator - Pin B45
PTC11/I2C0_SDA Primary Elevator - Pin A8 -> PTD3/I2C1_SDA Primary Elevator - Pin B44
GND Primary Elevator - Pin A65 -> GND Primary Elevator - Pin A65

TWR-K21F120M Tower System module

TWR-K21F120M Single Board
Master Connects To Slave
Pin Name Board Location Pin Name Board Location
PTD2/I2C0_SCL Primary Elevator B45 -> PTC10/I2C1_SCL Primary Elevator B50
PTD3/I2C0_SDA Primary Elevator B44 -> PTC11/I2C1_SDA Primary Elevator B51


TWR-K21F120M Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
PTD2/I2C0_SCL Primary Elevator B45 -> PTC10/I2C1_SCL Primary Elevator B50
PTD3/I2C0_SDA Primary Elevator B44 -> PTC11/I2C1_SDA Primary Elevator B51
GND Primary Elevator - Pin A65 -> GND Primary Elevator - Pin A65

TWR-K22F120M Tower System module

TWR-K22F120M Single Board
Master Connects To Slave
Pin Name Board Location Pin Name Board Location
I2C0_SCL Primary Elevator - Pin A7 -> I2C1_SCL Primary Elevator - Pin B50
I2C0_SDA Primary Elevator - Pin A8 -> I2C1_SDA Primary Elevator - Pin B51


TWR-K22F120M Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
I2C0_SCL Primary Elevator - Pin A7 -> I2C1_SCL Primary Elevator - Pin B50
I2C0_SDA Primary Elevator - Pin A8 -> I2C1_SDA Primary Elevator - Pin B51
GND Primary Elevator - Pin A65 -> GND Primary Elevator - Pin A65

TWR-K24F120M Tower System module

TWR-K24F120M Single Board
Master Connects To Slave
Pin Name Board Location Pin Name Board Location
I2C0_SCL Primary Elevator A7 -> I2C1_SCL Primary Elevator B50
I2C0_SDA Primary Elevator A8 -> I2C1_SDA Primary Elevator B51


TWR-K24F120M Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
I2C0_SCL Primary Elevator A7 -> I2C1_SCL Primary Elevator B50
I2C0_SDA Primary Elevator A8 -> I2C1_SDA Primary Elevator B51
GND Primary Elevator A6 -> GND Primary Elevator A6

TWR-K60D100M Tower System module

TWR-K60D100M Single Board
Master Connects To Slave
Pin Name Board Location Pin Name Board Location
I2C0_SCL Primary Elevator A7 -> I2C1_SCL Primary Elevator A75
I2C0_SDA Primary Elevator A8 -> I2C1_SDA Primary Elevator B71


TWR-K60D100M Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
I2C0_SCL Primary Elevator A7 -> I2C1_SCL Primary Elevator A75
I2C0_SDA Primary Elevator A8 -> I2C1_SDA Primary Elevator B71
GND Primary Elevator A6 -> GND Primary Elevator A6

TWR-K64F120M Tower System module

TWR-K64F120M Single Board
Master Connects To Slave
Pin Name Board Location Pin Name Board Location
I2C0_SCL Primary Elevator - Pin A7 -> I2C1_SCL Primary Elevator - Pin A75
I2C0_SDA Primary Elevator - Pin A8 -> I2C1_SDA Primary Elevator - Pin B71


TWR-K64F120M Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
I2C0_SCL Primary Elevator - Pin A7 -> I2C1_SCL Primary Elevator - Pin A75
I2C0_SDA Primary Elevator - Pin A8 -> I2C1_SDA Primary Elevator - Pin B71
GND Primary Elevator - Pin A65 -> GND Primary Elevator - Pin A65

TWR-K65F180M Tower System module

TWR-K65F180M Single Board
Master Connects To Slave
Pin Name Board Location Pin Name Board Location
I2C0_SCL Primary Elevator - Pin A7 -> I2C1_SCL Primary Elevator - Pin B11
I2C0_SDA Primary Elevator - Pin A8 -> I2C1_SDA Primary Elevator - Pin B22


TWR-K65F180M Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
I2C0_SCL Primary Elevator - Pin A7 -> I2C1_SCL Primary Elevator - Pin B11
I2C0_SDA Primary Elevator - Pin A8 -> I2C1_SDA Primary Elevator - Pin B22
GND Primary Elevator - Pin A65 -> GND Primary Elevator - Pin A65

TWR-KL43Z48M Tower System module

TWR-KL43Z48M Single Board
Master Connects To Slave
Pin Name Board Location Pin Name Board Location
I2C0_SCL Primary Elevator A40 -> I2C1_SCL Primary Elevator A7
I2C0_SDA Primary Elevator A39 -> I2C1_SDA Primary Elevator A8


TWR-KL43Z48M Two Boards
Master (Board #1) Connects To Slave (Board #2)
Pin Name Board Location Pin Name Board Location
I2C0_SCL Primary Elevator A40 -> I2C1_SCL Primary Elevator A7
I2C0_SDA Primary Elevator A39 -> I2C1_SDA Primary Elevator A8
GND Primary Elevator A6 -> GND Primary Elevator A6

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 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.

Run the demo

This menu displays on the terminal window:

Available Commands:
LED Red Toggle (1) - Red Light toggles on/off
LED Green Toggle (2) - Green Light toggles on/off
LED Blue Toggle (3) - Blue Light toggles on/off
Read Temperature (4) - Get temperature of client (It is necessary to set voltage reference exactly to 3.3V to see correct temperature.)
Read Id (5) - Read client unique ID

Enter your choice (1 - 5):

You can select to toggle the RGB LED, read the temperature of the client board, and read the client unique ID.

Note that a different colored LED may turn on if the selected color is not available on that board.