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

Overview

The DSPI Example project is a demonstration program that uses the KSDK software. This example provides 5 examples with 5 modes: DSPI polling, non-blocking, blocking, DMA blocking, DMA non blocking and DSPI loop-back.

Supported Platforms

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

System Requirement

Hardware requirements

Toolchain requirements

Software requirements

Getting Started

Hardware settings

FRDM-K22F :

Master Board Connects To Slave Board
Pin Name Board Location Pin Name Board Location
SPI0_SIN J1 pin 11 -> SPI0_SOUT J1 pin 16
SPI0_SOUT J1 pin 16 -> SPI0_SIN J11 pin 11
SPI0_CLK J1 pin 15 -> SCK J1 pin 15
SPIO_CS0 J24 pin 9 -> PCSO0 J24 pin 9
GND J2 pin 14 -> GND J2 pin 14


FRDM-KW24 :

Master Board Connects To Slave Board
Pin Name Board Location Pin Name Board Location
SPI0_SIN J2 pin 10 -> SPI0_SOUT J2 pin 8
SPI0_SOUT J2 pin 8 -> SPI0_SIN J2 pin 10
SPI0_CLK J2 pin 12 -> SCK J2 pin 12
SPI0_CS0 J2 pin 6 -> PCSO0 J2 pin 6
GND J2 pin 14 -> GND J2 pin 14


FRDM-K64F:

Master Board Connects To Slave Board
Pin Name Board Location Pin Name Board Location
SPI0_SIN J2 pin 10 -> SPI0_SOUT J2 pin 8
SPI0_SOUT J2 pin 8 -> SPI0_SIN J2 pin 10
SPI0_CLK J2 pin 12 -> SCK J2 pin 12
SPI0_SC0 J2 pin 6 -> PCSO0 J2 pin 6
GND J2 pin 14 -> GND J2 pin 14


TWR-K21D50M & TWR-K21F120M & TWR-K64F120M:

Master Board Connects To Slave Board
Pin Name Board Location Pin Name Board Location
SPI0_SIN Primary Elevator B44 -> SPI0_SOUT Primary Elevator B45
SPI0_SOUT Primary Elevator B45 -> SPI0_SIN Primary Elevator B44
SPI0_SCK Primary Elevator B48 -> SPI0_SCK Primary Elevator B48
SPI0_PCS0 Primary Elevator B46 -> SPI0_PCS0 Primary Elevator B46
GND Primary Elevator B2 -> GND Primary Elevator B2


TWR-K22F120M & TWR-K24F120M & TWR-KV10Z32 & TWR-KV31F120M & TWR-K24WD512:

Master Board Connects To Slave Board
Pin Name Board Location Pin Name Board Location
SPI0_SIN Primary Elevator B44 -> SPI0_SOUT Primary Elevator B45
SPI0_SOUT Primary Elevator B45 -> SPI0_SIN Primary Elevator B44
SPI0_CLK Primary Elevator B48 -> SPI0_CLK Primary Elevator B48
SPI0_CS0 Primary Elevator B46 -> SPI0_CS0 Primary Elevator B46
GND Primary Elevator B2 -> GND Primary Elevator B2


TWR-K60D100M:

Master Board Connects To Slave Board
Pin Name Board Location Pin Name Board Location
MISO Primary Elevator A77 -> MISO Primary Elevator A76
MOSI Primary Elevator A76 -> MOSI Primary Elevator A77
SCK Primary Elevator B64 -> SCK Primary Elevator B64
PCSO0 Primary Elevator A63 -> PCSO0 Primary Elevator A63
GND Primary Elevator B2 -> GND Primary Elevator B2


TWR-K65F180M:

Master Board Connects To Slave Board
Pin Name Board Location Pin Name Board Location
MISO Primary Elevator B19 -> MISO Primary Elevator B20
MOSI Primary Elevator B20 -> MOSI Primary Elevator B19
SCK Primary Elevator B15 -> SCK Primary Elevator B15
PCSO0 Primary Elevator A16 -> PCSO0 Primary Elevator A16
GND Primary Elevator B2 -> GND Primary Elevator B2


TWR-KV46F150M:

Master Board Connects To Slave Board
Pin Name Board Location Pin Name Board Location
MISO Primary Elevator A37 -> MISO Primary Elevator A38
MOSI Primary Elevator A38 -> MOSI Primary Elevator A37
SCK Primary Elevator A39 -> SCK Primary Elevator A39
PCSO0 Primary Elevator A40 -> PCSO0 Primary Elevator A40
GND Primary Elevator B2 -> GND Primary Elevator B2


Prepare the example

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

Run the example

DSPI blocking Master-Slave

Note: On the TWR-K65F180M board, ensure that all TWR-SERs are rejected. Set up the slave first and the slave board displays this message on the terminal:

DSPI board to board blocking example
This example run on instance 0
Be sure DSPI0-DSPI0 are connected
Slave example is running...

The master sends an array to the slave and receives the array back from the slave. It also compares whether the two buffers are the same. The master board prints this message on the terminal:

DSPI board to board blocking example
This example run on instance 0
Be sure DSPI0-DSPI0 are connected
Transfer at baudrate 468750
Master transmit:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
Master receive:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
DSPI Master Sends/ Receives successfully
Press any key to run again

The slave board receives and prints this message on terminal:

Slave receive:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
Slave example is running...

DSPI non-blocking Master-Slave

Set up the slave first and the slave board displays this message on the terminal:

DSPI board to board non-blocking example
This example run on instance 0
Be sure DSPI0-DSPI0 are connected
Slave example is running...

The master sends an array to the slave and receives the array back from the slave. It also compares whether the two buffers are the same. The master board prints this message on the terminal:

DSPI board to board non-blocking example
This example run on instance 0
Be sure DSPI0-DSPI0 are connected
Transfer at baudrate 468750
Master transmit:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
Master receive:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
DSPI Master Sends/ Receives successfully
Press any key to run again

The slave board receives and prints this message on the terminal:

Slave receive:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
Slave example is running...

DSPI edma blocking Master-Slave

Set up the slave first and the slave board displays this message on the terminal:

DSPI board to board EDMA blocking example
This example run on instance 0
Be sure DSPI0-DSPI0 are connected
Slave example is running...

The master sends an array to the slave and receives the array back from the slave. It also compares whether the two buffers are the same. The master board print this message on the terminal:

DSPI board to board edma-blocking example
This example run on instance 0
Be sure DSPI0-DSPI0 are connected
Transfer at baudrate 468750
Master transmit:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
Master receive:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
DSPI Master Sends/ Receives successfully
Press any key to run again

The slave board will receive and print on terminal:

Slave receive:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
Slave example is running...

DSPI edma non-blocking Master-Slave

Set up the slave first and the slave board displays this message on the terminal:

DSPI board to board EDMA non-blocking example
This example run on instance 0
Be sure DSPI0-DSPI0 are connected
Slave example is running...

The master sends an array to the slave and receives the array back from the slave. It also compares whether the two buffers are the same. The master board prints this message on the terminal:

DSPI board to board edma-non-blocking example
This example run on instance 0
Be sure DSPI0-DSPI0 are connected
Transfer at baudrate 468750
Master transmit:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
Master receive:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
DSPI Master Sends/ Receives successfully
Press any key to run again

The slave board receives and prints this message on terminal:

Slave receive:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
Slave example is running...

DSPI polling Master-Slave

Set up the slave first and the slave board displays this message on the terminal:

DSPI board to board polling example
This example run on instance 0
Be sure DSPI0-DSPI0 are connected
Slave example is running...

The master sends an array to the slave and receives the array back from the slave. It also compares whether the two buffers are the same. The master board displays this message on the terminal:

DSPI board to board polling example
This example run on instance 0
Be sure DSPI0-DSPI0 are connected
Transfer at baudrate 468750
Master transmit:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
Master receive:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
DSPI Master Sends/ Receives successfully
Press any key to run again

The slave board receives and prints this message on the terminal:

Slave receive:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
Slave example is running...

DSPI Loopback

These instructions are displayed/shown on the terminal window:

DSPI master self loopback example
This example run on instance 0
Be sure MISO-to-MOSI are connected
Transfer at baudrate 468750
Master transmit:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
Master receive:
01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20
DSPI Sends/ Receives successfully
Press any key to run again