Skip to content

ARMmbed/example-asynch-spi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Asynchronous SPI Example

This repository is an example for asynchronous SPI. It is a test unit with test cases for asynchronous SPI methods, using a loopback (MOSI connected to MISO).

Pre-requisites

To build and run this example the following requirements are necessary:

  • A computer with the following software installed:
  • An FRDM-K64F development board.
  • A micro-USB cable.
  • A wire to connect MOSI to MISO.
  • If your OS is Windows, please follow the installation instructions for the serial port driver.

Pins

MISO, MOSI and SSEL pin definitions are target-specific. To function correctly, the code and the physical board must both be using the same pins. Follow these steps to determine which pins the code is configured to use.

  1. First, find the pin references in the source files. In this example, view spi_asynch.cpp. The pin references are YOTTA_CFG_HARDWARE_TEST_PINS_SPI_MISO, YOTTA_CFG_HARDWARE_TEST_PINS_SPI_MOSI and YOTTA_CFG_HARDWARE_TEST_PINS_SPI_SSEL.

  2. Next, find these target-specific pin references in the configuration data by running the command:

yotta config
Each keyword in the pin reference represents a level in the target configuration structure.  To find what YOTTA_CFG_HARDWARE_TEST_PINS_SPI resolves to, look under config/hardware/test-pins/spi.

The spi pins for K64F are:

```
"spi": {
  "mosi": "PTD2",
  "miso": "PTD3",
  "sclk": "PTD1",
  "ssel": "PTD0"
}
```
  1. Locate the MOSI and MISO pins (i.e. PTD2, PTD3) on the board's pinout picture:

  2. Finally, create a loopback, connect the MISO and MOSI pins together by a wire.

Getting started

  1. Connect the FRDM-K64F to the computer with the micro-USB cable, being careful to use the micro-USB port labeled "OpenSDA".

  2. Assuming you have cloned this repository or receive it with a release tarball, open a terminal window and navigate to the repository's folder.

    cd /path/to/example-asynch-spi
    
  3. Select the yotta target and build to it:

    yotta target frdm-k64f-gcc
    yotta build
    
  4. Connect YOTTA_CFG_HARDWARE_TEST_PINS_SPI_MOSI to YOTTA_CFG_HARDWARE_TEST_PINS_SPI_MISO with a cable. See the previous section for an explanation if you do not know how to locate these.

  5. Copy build/frdm-k64f-gcc/source/example-asynch-spi.bin to your mbed board and wait until the LED next to the USB port stops blinking.

  6. Start the serial terminal emulator and connect to the virtual serial port presented by FRDM-K64F. For settings, use 115200 baud, 8N1, no flow control.

  7. Press the reset button on the board.

  8. The output in the terminal should look like this:

    Starting short transfer test
    Res is 0
    Short transfer DONE, event is 4
    Starting long transfer test
    Res is 0
    Long transfer DONE, event is 4
    **** Test done ****