SAM3S8/SD8 Software Package: SPI Slave Example

SAM3S8/SD8 Software Package 1.2

# SPI Slave Example

## Purpose

This example uses Serial Peripheral Interface (SPI) in slave mode to communicate to another SPI master) interface.

## Requirements

This package can be used with two sam3s-ek2 board. Please connect the SPI pins from one board to another.

- SAM3S(MASTER)--SAM3S(SLAVE)
- NPCS0 -- NPCS0 (PA11)
- MISO -- MISO (PA12)
- MOSI -- MOSI (PA13)
- SPCK -- SPCK (PA14)
- GND -- GND Because PA11 is multiplexed with ADS7843 (by default) and this example, so please remove R66 on the EK board to make PA11 is dedicated to this example.

## Descriptions

This example shows control of the SPI slave, how to configure and transfer data with SPI slave. By default, example runs in SPI slave mode, waiting SPI slave & UART inputs.

The code can be roughly broken down as follows:

- 't' will start SPI transfer test
  1. Configure SPI as master, setup SPI clock.
  2. Send 4 byte CMD_TEST to indicate the start of test.
  3. Send several 64 bytes block, on transmitting next block, the content of last block is returned.
  4. Send CMD_STATUS command and waiting for the status reprots from slave.
  5. Send CMD_END command to indicate the end of test.
- Setup SPI clock for master.

## Usage

1. Compile the application.
2. Connect the UART port of the evaluation board to the computer and open it in a terminal.
   - Settings: 115200 bauds, 8 bits, 1 stop bit, no parity, no flow control.
3. Download the program inside the evaluation board and run it. Please refer to SAM-BA User Guide, the GNU-Based Software Development application note or to the IAR EWARM User and reference guides, depending on your chosen solution.
4. Upon startup, the application will output the following line on the terminal:

            -- Spi slave Example  xxx --
            -- xxxxxx-xx
            -- Compiled: xxx xx xxxx xx:xx:xx --

5. The following traces detail operations on the spl slave example, displaying success or error messages depending on the results of the commands.

## References

- spi_slave/main.c
- spi.c

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines