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.
- DSPI board to board:
- Transfers data through instance 0 of SPI interface. SPI0 pins of the master board are connected to the SPI0 pins of the slave board.
- It is important to ensure all SPI board-to-board connections are kept as short as possible and that a solid ground wire is connected between the boards. Preferably this ground connection should be as close as possible to the SPI signals on each board. A poor board-to-board connection compromises data signal integrity causing failures in the example.
- 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 slave sends back the received buffer from the master. (*) (Power up slave first)
- DSPI master loop-back:
- Transfer data through instance 0 of SPI interface. The MISO pin and MOSI pin are connected.
- Sends an array out through the MISO pin and compares it with the received buffer from the MOSI pin.
Supported Platforms
These Freescale Freedom development platforms and Tower System modules are supported by the DSPI example.
- FRDM-K22F
- FRDM-K64F
- FRDM-KW24
- TWR-K21D50M
- TWR-K21F120M
- TWR-K22F120M
- TWR-K24F120M
- TWR-K60D100M
- TWR-K64F120M
- TWR-K65F180M
- TWR-KV10Z32
- TWR-KV31F120M
- TWR-KV46F150M
- TWR-KW24D512
System Requirement
Hardware requirements
- J-Link ARM
- P&E Micro Multi-link universal
- Mini/micro USB cable
- USB A to micro AB cable
- Hardware (tower/base board, ...) for specific device
- Personal Computer
Toolchain requirements
- IAR embedded Workbench version 7.30.4
- ARM GCC 4.8.3 2014q3
- Keil MDK 5.13
- Kinetis Design Studio IDE v.2.5.0
- Atollic TrueSTUDIO for ARM win32 v5.2.1
Software requirements
- The project files are in: <SDK_Install>/examples/<board>/driver_examples/dspi/<use_case>/<toolchain>.
- Library dependencies: ksdk_platform_lib
Getting Started
Hardware settings
- DSPI master loopback:
- Transfers data through the instance 0 of the SPI interface. The MISO pin and MOSI pin are connected.
- DSPI board to board:
- Transfers data through the instance 0 of the SPI interface. SPI0 pins of the master board are connected to the SPI0 pins of the slave board.
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
- Connect a USB cable between the PC host and the OpenSDA USB port on the board.
- Open a serial terminal with these settings:
- 115200 baud rate
- 8 data bits
- No parity
- One stop bit
- No flow control
- Download the program to the target board.
- 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
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
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
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
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
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
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
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
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
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
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
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