1 Star 1 Fork 0

Microchip_MPLAB_Harmony / csp_apps_sam_a5d2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
GUID-FD282B3E-147F-41FF-A097-05B81B5036E4.md 4.42 KB
一键复制 编辑 原始数据 按行查看 历史

SPI Master Read Write Test Application

This is a SPI Master test application which is provided to demonstrate communication
between SPI Master and the corresponding SPI Slave application available under -apps/spi/slave/spi_write_read/firmware

Parent topic:Harmony 3 Peripheral Library Application Examples for SAMA5D2 Family

Description

This example uses the SPI peripheral library in Master mode and serves as a test
application to demonstrate communication between SPI Master and corresponding SPI
Slave application available at apps/spi/slave/spi_write_read/firmware.

The SPI Master writes data by sending a write command followed by two bytes of memory
address followed by the data to be written.

< WR_CMD > < ADDR_MSB > < ADDR_LSB > < DATA0 > … < DATA n >

The SPI Slave asserts the Busy line to indicate to the SPI Master that it is busy.
Once ready, the SPI Slave de-asserts the Busy line. Once the SPI Slave is ready, the
SPI Master reads the data by sending read command followed by two bytes of memory
address and the number of bytes to read.

< RD_CMD > < ADDR_MSB > < ADDR_LSB > < NUM_BYTES >

The SPI Slave responds by sending the data at the requested memory address. The SPI
Master compares the sent data with the received data and repeats the test if it
matches.

Downloading and Building the Application

To clone or download this application from Github, go to the main page of this repository and then
click Clone button to clone this repository or download as zip file. This content
can also be downloaded using content manager by following these instructions.

Path of the application within the repository is
apps/spi/master/spi_write_read_test_app/firmware.

To build the application, refer to the following table and open the project using its
IDE.

Project Name Description
sam_a5d2_curiosity.X MPLABX project for SAMA5D29 Curiosity Development Board Kit

Setting Up AT91Bootstrap Loader

To load the application binary onto the target device, we need to use at91bootstrap
loader. Refer to the at91bootstrap loader documentation for
details on how to configure, build and run bootstrap loader project and use it to
bootstrap the application binaries.

Setting Up the Hardware

The following table shows the target hardware for the application projects.

Project Name Description
sam_a5d2_curiosity.X SAMA5D29 Curiosity Development Board Kit

Setting Up SAMA5D29 Curiosity Development Board

SETTING UP THE BOARD

  • To run this demo two SAMA5D29 Curiosity Development Board Kit are required. One will be programmed as SPI Master and other will be programmed as SPI Slave.
  • Connect Pin 3, 4, 5, 6 on mikroBUS1 of SPI slave to Pin 3, 4, 5, 6 on mikroBUS1 of SPI master
    • Pin 3 - SPI Chip Select
    • Pin 4 - SCK
    • Pin 5 - MISO
    • Pin 6 - MOSI
  • Connect Pin 1 on mikroBUS1 of SPI slave to Pin 1 on mikroBUS1 of SPI master. Pin 1 is configured as GPIO and serves as the slave busy pin.
  • Connect the Debug USB port on the board to the computer using a Type-C USB cable

Running the Application

  1. Build and Program the SPI Master application project using its IDE on board.
  2. Build and Program the SPI Slave application project using its IDE. Path of the SPI Slave application within the repository is apps/spi/slave/spi_write_read/firmware on another board.
  3. On the SPI Master board, press switch to start reading and writing data
  4. LED on SPI Master board indicates the success or failure:
    • LED is turned ON when the data read from the SPI Slave matches with the data written
    • LED is turned OFF when the data read from the SPI Slave does not match with the data written

Following table provides the Switch and LED names:

Board Switch Name LED Name
SAMA5D29 Curiosity Development Board USER RGB_LED (Green)
1
https://gitee.com/Microchip-MPLAB-Harmony/csp_apps_sam_a5d2.git
git@gitee.com:Microchip-MPLAB-Harmony/csp_apps_sam_a5d2.git
Microchip-MPLAB-Harmony
csp_apps_sam_a5d2
csp_apps_sam_a5d2
master

搜索帮助