Page 1
Using the Serial Peripheral Interface (SPI) with AT91SAMxx Devices AT91 ARM 1. Introduction Thumb This application note describes the use of the Serial Peripheral Interface (SPI) imple- ® ® mented in AT91SAMxx ARM Thumb -based devices. Microcontrollers In this application note: •...
2. SPI Features • Supports Communication with Serial External Devices – Four Chip Selects with External Decoder Support Allow Communication with Up to 15 Peripherals – Serial Memories, such as DataFlash and 3-wire EEPROMs – Serial Peripherals, such as ADCs, DACs, LCD Controllers, CAN Controllers and Sensors –...
Application Note 4. Interfacing the SPI The following figure shows two AT91SAMxx devices exchanging data through the SPI bus. Figure 4-1. Interfacing the SPI AT91SAMxx AT91SAMxx SPI Master SPI Slave SPCK SPCK MOSI MOSI MISO MISO NPCS0 NPCS1 NSS/NPCS0 NPCS2 NPCS3 SPCK waveforms are PHA = 0...
Page 4
Clock (SPCK) and selection signals (NPCS) are provided by the Master. • The clock has to be compatible with the Slave in terms of waveform (phase and polarity) and speed. In the case where the master addresses an AT91SAMxx device the waveform has no restriction and the maximum operating baud rate is (Slave Master Clock) / 2.
Page 5
Application Note Figure 4-2. DLYBS, BLYBCT and DLYBCS Start transfer End transfer DLYBS ! = 0 CSAAT = 1 NPCS SPCK MOSI Example N˚1: A delay between the falling edge of the CS and the first clock edge has been programmed (DLYBS ! = 0). CS remains active at the end of the transfer (CSAAT = 1).
Page 6
5. Initialization The flowchart in Figure 5-1 depicts initialization of the SPI in either Master or Salve mode. Figure 5-1. SPI Initialization Start Initialization Configure SPI PIO Function: AT91F_SPIx_CfgPIO () Enable SPI in the PMC Function: AT91F_SPIx_CfgPMC () Slave Master ? Configure the SPI -->...
Page 7
Application Note 6. Use of Last Transfer Last Transfer is used to make the current Chip Select rise under the conditions listed below. • The data transfer is finished: – the shift register is empty, no new data has been written in the transmit register and DLYBCT is finished.
It is important to note that the hardware support used to develop this software was an AT91SAM7S-EK board that includes an AT91SAM7S256. Atmel.com has more information on the AT91SAM7S-EK. Figure 7-1 shows the connection between the Master and the Slave.
Application Note Software Flowchart The flowchart shown in Figure 7-2 illustrates the software example. Figure 7-2. Software Example Start Slave Slave Master/Slave ? Master/Slave ? Master config is Master config is Pha = Pol = 1 Pha = Pol = 0 Slave config is Slave config is Data length = 16 bits...
Revision History Change Doc. Rev Comments Request Ref. 6229A First issue 6229B Remove references to internal documents 3017 Application Note 6229B–ATARM–06-Aug-06...
Page 11
Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN ATMEL’S TERMS AND CONDI- TIONS OF SALE LOCATED ON ATMEL’S WEB SITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY...
Need help?
Do you have a question about the AT91 ARM and is the answer not in the manual?
Questions and answers