Serial Peripheral Interface (SPI) Host Controller Data Sheet

Similar documents
The 9S12 Serial Peripheral Inteface (SPI) Huang Section 10.2 through 10.6 SPI Block User Guide

SPI Block User Guide V02.07

Module 3.C. Serial Peripheral Interface (SPI) Tim Rogers 2017

More on the 9S12 SPI Using the Dallas Semiconductor DS1302 Real Time Clock with the 9S12 SPI

EE 308 Spring Using the 9S12 SPI

spi 1 Fri Oct 13 13:04:

Creating Power-Efficient Designs with the ArcticLink Solution Platform

ArcticLink III BX5 Solution Platform Data Sheet

a Serial Peripheral Interace (SPI). Embedded RISC Microcontroller Core Peripheral

Section 5 SERCOM. Tasks SPI. In this section you will learn:

ECE 4510/5530 Microcontroller Applications Week 6

Secure Digital Input/Output (SDIO) Host Controller Data Sheet

EE 456 Fall, Table 1 SPI bus signals. Figure 1 SPI Bus exchange of information between a master and a slave.

An SPI interface for the 65(C)02 family of microprocessors

OUTLINE. SPI Theory SPI Implementation STM32F0 SPI Resources System Overview Registers SPI Application Initialization Interface Examples

Discontinued IP. Slices. LUTs. FFs. Block RAMs. Instantiation

Review for Exam 3. Write 0x05 to ATD0CTL4 to set at fastest conversion speed and 10-bit conversions

An SPI Temperature Sensor Interface with the Z8 Encore! SPI Bus

USER GUIDE EDBG. Description

ECE 4510 Introduction to Microprocessors. Chapter 10

EDBG. Description. Programmers and Debuggers USER GUIDE

Embedded Systems and Software. Serial Interconnect Buses I 2 C (SMB) and SPI

Addressing scheme to address a specific devices on a multi device bus Enable unaddressed devices to automatically ignore all frames

Application Note, V1.0, Jul AP XC16x. Interfacing the XC16x Microcontroller to a Serial SPI EEPROM. Microcontrollers

Synchronous = SPI (3 options)

Design with Microprocessors

SPI 3-Wire Master (VHDL)

Serial Peripheral Interface (SPI)

Each I2C master has 8-deep transmit and receive FIFOs for efficient data handling. SPI to Dual I2C Masters. Registers

Using the Z8051 MCU s USI Peripheral as an SPI Interface

AREA OPTIMIZATION OF SPI MODULE USING VERILOG HDL

For reference only Refer to the latest documents for details

8-bit RISC Microcontroller. Application Note. AVR151: Setup And Use of The SPI

Emulating Dual SPI Using FlexIO

DataFlash. Application Note. Using Atmel s DataFlash. Introduction (AN-4)

i_csn i_wr i_rd i_cpol i_cpha i_lsb_first i_data [15:0] o_data [15:0] o_tx_ready o_rx_ready o_rx_error o_tx_error o_tx_ack o_tx_no_ack

Serial Peripheral Interface (SPI)

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

< W3150A+ / W5100 Application Note for SPI >

Serial Peripheral Interface (SPI) Last updated 8/7/18

Understanding SPI with Precision Data Converters

McMaster University Embedded Systems. Computer Engineering 4DS4 Lecture 6 Serial Peripherals Amin Vali Feb. 2016

C8051F700 Serial Peripheral Interface (SPI) Overview

Section 16. Basic Sychronous Serial Port (BSSP)

Getting Started with ESPI Interface Using the Z8 Encore! XP F1680

Microcontrollers and Interfacing

Serial Peripheral Interface Bus SPI

ArduCAM-M-2MP Camera Shield

PIC Serial Peripheral Interface (SPI) to Digital Pot

ED1021 I/O Expander with UART interface & analog inputs

DQSPI IP Core. Serial Peripheral Interface Master/Slave with single, dual and quad SPI Bus support v. 2.01

QuickLogic TAG-N System User Manual

AT89S4D12. 8-Bit Microcontroller with 132K Bytes Flash Data Memory AT89S4D12. Features. Description. Pin Configurations

LogiCORE IP AXI Quad Serial Peripheral Interface (AXI Quad SPI) (v1.00a)

APPLICATION NOTE. Atmel AT02260: Driving AT42QT1085. Atmel QTouch. Features. Description

Hello, and welcome to this presentation of the STM32 Universal Synchronous/Asynchronous Receiver/Transmitter Interface. It covers the main features

Introduction to Serial Communication. ECE/CS 5780/6780: Embedded System Design. A Serial Channel. Definitions. SCI versus SPI.

AN2737 Application note Basic in-application programming example using the STM8 I 2 C and SPI peripherals Introduction

ECE/CS 5780/6780: Embedded System Design. Introduction to Serial Communication

CS/ECE 5780/6780: Embedded System Design

Menu. What is SPI? EEL 3744 EEL 3744 SPI

Serial Communication. Simplex Half-Duplex Duplex

Raspberry Pi - I/O Interfaces

Ethernet1 Xplained Pro

SPI: Serial Peripheral Interface

EE 308: Microcontrollers

UART Register Set. UART Master Controller. Tx FSM. Rx FSM XMIT FIFO RCVR. i_rx_clk o_intr. o_out1 o_txrdy_n. o_out2 o_rxdy_n i_cs0 i_cs1 i_ads_n

The SPI supports data bus widths of 32 bits.

Serial Communication. Spring, 2018 Prof. Jungkeun Park

AN510 Using SPI protocol with pressure sensor modules

1 Contents 2 2 Overview 3 3 Hardware Interface 4 4 Software Interface Register Map Interrupts 6 5 Revision History 8

AppNote-US2400-EVB Low Power 2.4GHz Transceiver

SRL0 Serial Port Unit

M68HC08 Microcontroller The MC68HC908GP32. General Description. MCU Block Diagram CPU08 1

LAB4. Program the on chip SPI module

DISCONTINUED. SPI Communication with AMT bit Absolute Encoder

APIX AUTOMOTIVE SHELL SW-EMULATION USE CASE

EE345L Fall 2008 Final Page 1 of 12

SPI Overview and Operation

Introducing SPI Xpress SPI protocol Master / Analyser on USB

Lecture 14 Serial Peripheral Interface

Frequently Asked Questions

P_D_OUT[31:0] SPI_INT SPI_MOSI_OUT SPI_MOSI_OEN

AN Sleep programming for NXP bridge ICs. Document information

power supply Tamper Detect function will detect possible data modification from outside magnetic

CapSense I 2 C/SPI Timer Flash RAM

Enhanced Serial Peripheral Interface (espi)

Level Shifter. for. Hardware User s Manual.

Amarjeet Singh. January 30, 2012

LAN bit Non-PCI Small Form Factor 10/100 Ethernet Controller with Variable Voltage I/O & HP Auto-MDIX Support PRODUCT FEATURES.

AN-145 ARINC 429 / SPI Demonstration board HI-3585, HI-3598/HI-3599 Applications Note

APPLICATION NOTE. AT11008: Migration from ATxmega16D4/32D4 Revision E to Revision I. Atmel AVR XMEGA. Introduction. Features

Lecture 25 March 23, 2012 Introduction to Serial Communications

Universität Dortmund. IO and Peripheral Interfaces

Design Development and Implementation of SPI

ice40 UltraPlus I 2 C and SPI Hardened IP Usage Guide Radiant Software

Serial DataFlash. Application Note. Using Atmel s Serial DataFlash. Introduction (AN-4)

Asynchronous & Synchronous Serial Communications Interface. Student's name & ID (1): Partner's name & ID (2): Your Section number & TA's name

Serial Buses in Industrial and Automotive Applications

IV B.Tech. I Sem (R13) ECE : Embedded Systems : UNIT -4 1 UNIT 4

Transcription:

Serial Peripheral Interface (SPI) Host Controller Data Sheet Proven System Block (PSB) for QuickLogic Customer Specific Standard Products (CSSPs) Features Supports Master configuration (Multi-Master configuration is not supported). Capable of being connected to eight SPI slaves with individual slave select lines. Supports Normal and Bidirectional modes of operation. Interrupt generation capability (transmitter and receiver operations are accomplished through interrupts to the processor from either the Transmit or Receive FIFO. Serial clock with programmable phase and polarity. Supports speeds of up to one-half of the system clock. Four programmable transfer formats supported (controlled by CPOL and CPHA). Buffered operation with separate transmit and receive FIFO 1024-byte deep for post preamble data transfer. Maximum bit rate of 20 Mbits/sec. with a system clock of 40 MHz. 1.8/2.5/3.3 V I/O voltages are supported. Supports up to 4 bytes of preamble (for transferring the address and the instructions). Arbitrary choice of message size, contents, and purpose. Overview The QuickLogic SPI Host controller can communicate with up to eight SPI slave devices. To achieve a high throughput of 20 Mbits/sec., the SPI controller utilizes a 32-bit processor interface and two 8-Kbit FIFOs (Tx and Rx). The microprocessor interface can push/pop data 32 bits at a time, while the SPI transmits/receives 8 bits at a time. Transmitter and receiver operations are accomplished through interrupts to the processor from either the Transmit or Receive FIFO. The Write Interrupt is triggered when the Transmit FIFO is empty and the Read Interrupt is triggered when the received bytes count equals the preset value. 2008 QuickLogic Corporation www.quicklogic.com 1

SPI Host Controller Architecture The SPI Host Controller is a full-duplex synchronous serial input/output data connection that is standard on many embedded processors. It is traditionally used to interact with slow peripheral devices such as EEPROMs, real-time clocks and analog-to-digital converters (ADCs). However with the increasing speed, SPI also evolved to become a standard interface to wireless LAN 802.11a/b/g as well as mobile TV chipsets. QuickLogic SPI Host controller is designed to interface with different CPU interfaces and up to eight SPI slave devices. The internal high speed serializer/deserializer and FIFOs ensure high data rate of 20 Mbit/sec. to meet WiFi and mobile television requirements. Figure 1 shows a top-level block diagram of the QuickLogic SPI Host Controller. The microprocessor interface is customizable to any microprocessor. Figure 1: SPI Host Controller Architecture Block Diagram QuickLogic FIFOs Micro Processor Local Bus Processor Interface Host Registers SPI Host/Slave Controller Baud Generator Serializer- Deserializer SCK MOSI MISO SS_bar[7] SS_bar[6]. SS_bar[0] SPI Slaves Interface List and Description The SPI module has a total of 11 external pins for the slave interface and 43 for the processor interface. The processor interface is customizable for different processor interfaces. Table 1 shows an example pin description for the PXA270 processor which includes the name, type, description of the ports, and the inputs/outputs that can connect off chip. PXAxxx VLIO Interface Table 1: SPI PXA270 Pin Description Pin Type Description CPU_DATA[31:0] I/O VLIO data bus. CPU_ADDR[4:2] I VLIO address bus. Signals the address requested for memory accesses. CPU_RDnWR I VLIO Interface Read /not Write indicator. CPU_RDY I VLIO active high Ready signal. CPU_nBE[3:0] I VLIO active low Byte Enable Bus. 2 www.quicklogic.com 2008 QuickLogic Corporation

Table 1: SPI PXA270 Pin Description (Continued) Pin Type Description CPU_CS I VLIO active low Chip Select. CPU_INT O VLIO interrupt. SPI Interface SCK I/O Serial Clock (output from the Master). SS_bar0 I/O Slave Select 0 (active low, output from the Master). SS_bar1 I/O Slave Select 1 (active low, output from the Master). SS_bar2 I/O Slave Select 2 (active low, output from the Master). SS_bar3 I/O Slave Select 3 (active low, output from the Master). SS_bar4 I/O Slave Select 4 (active low, output from the Master). SS_bar5 I/O Slave Select 5 (active low, output from the Master). SS_bar6 I/O Slave Select 6 (active low, output from the Master). SS_bar7 I/O Slave Select 7 (active low, output from the Master). MOSI I/O Master Output, Slave Input (output from the Master). MISO I/O Master Input, Slave Output (output from the Slave). Register Sets Table 2 shows the memory map of the SPI register set. There are five registers that control the SPI operation. The address listed for each register is the offset from the base address of the chip select of the processor. Table 2: SPI Register Set Memory Map Address Description Access 0x00 SPI Configuration Register Read/Write a 0x04 Reserved 0x08 Preamble Register Write 0x0C SPI Transfer Register Write 0x10 SPI Interrupt Register Read 0x14 Slave Select Register Write 0x18 Write FIFO Port Write 0x1C Read FIFO Port Read a. Some bits are read-only. SPI Configuration Register (offset 0x00) Select SCK phase and polarity Master and Slave modes Interrupt flag enable Baud rate setting Normal/Bidirectional mode of operation 2008 QuickLogic Corporation www.quicklogic.com 3

Preamble Register (offset 0x08) This register is optional and can contain a combination of address bytes and opcode SPI Transfer Register (offset 0x0C) Start/Stop control Number of bytes to be transmitted/received Read/Write control Byte enable for the Preamble Register SPI Interrupt Register (offset 0x10) Read Interrupt Write Interrupt Processor Interrupt Slave Select Register (offset 0x14) Eight external slave select bits Table 3 shows the SPI register set in more detail. Table 3: Register Set Byte 3 Byte 2 Byte 1 Byte 0 Offset SPISR SPIBR SPICR2 SPICR1 0x00 UNUSED (Reserved) 0x04 PREAMBLE 0x08 BE[3] BE[2] BE[1] BE[0] # of data_bytes[15:3] R W S/Sp 0x0C IP IW IR 0x10 S7 S6 S5 S4 S3 S2 S1 S0 0x14 WRITE FIFO PORT 0x18 READ FIFO PORT 0x1C 4 www.quicklogic.com 2008 QuickLogic Corporation

Register Descriptions This section provides a detailed description of all the registers in the SPI Host Controller and the corresponding bits. Register: SPICR1 (Offset 0x00, Byte 0) The SPI control register 1(SPICR1) should be written to only when a transaction is not in progress. This register configures the SPI Host Controller. It controls the mode of operation (Master/Slave), the phase and polarity of the clock, and the transfer type (LSB or MSB first). Table 4: SPI Control Register 1 (SPICR1) Bit[7] Bit[6] Bit[5] Bit[4] Bit[3] Bit[2] Bit[1] Bit[0] SPIE SPE Rsv MSTR CPOL CPHA Rsv LSBFE Bit 1 and Bit 5 are not implemented (reads or writes to these bits are not implemented). They are reserved for future use. After system reset the following register bits are set to the default values. Table 5: SPICR1 Bits 0x00[7:0] Bits Type Description Default Value Bit[0] R/W LSBFE: This bit does not affect the position of the MSB and LSB in the data register. Reads and writes of the data register always have the MSB in bit 7. 1 = Data is transferred LSB first. 0 = Data is transferred MSB first. Bit[1] - N/A 0 CPHA: This bit is used to shift the SCK serial clock. 0 Bit[2] R/W 1 = The first SCK edge is issued at the beginning of the 8-cycle transfer operation. 1 0 = The first SCK edge is issued one-half cycle into the 8-cycle transfer operation. Bit[3] R/W CPOL: SPI clock polarity bit. This bit selects an inverted or non-inverted SPI clock. To transmit data between SPI modules, the SPI modules must have identical CPOL values. 0 1 = Active-low clocks selected; SCK idles high. 0 = Active-high clocks selected; SCK idles low. MSTR: SPI Master/Slave mode select bit. Bit[4] R/W 1 = Master mode. 0 0 = Slave mode. 2008 QuickLogic Corporation www.quicklogic.com 5

Bit[5] - N/A 0 Bit[6] Bit[7] R/W R/W SPE: SPI system enable bit. This bit enables the SPI system and dedicates the SPI port pins to SPI system functions. 1 = SPI port pins are dedicated to SPI functions. 0 = SPI disabled (lower power consumptions). SPIE: SPI interrupt enable bit. This bit enables SPI interrupts each time the SPIF or MODF status flag is set. 1 = SPI interrupts enabled. 0 = SPI interrupts disabled. Register: SPICR2 (Offset 0x00, Byte 1) The SPI control register 2(SPICR2) should be written to only when a transaction is not in progress. This register controls the mode of operation (Normal/Bidirectional) and enables the bidirectional pin configuration. Table 6: SPI Control Register 2 (SPICR2) Bit[15] Bit[14] Bit[13] Bit[12] Bit[11] Bit[10] Bit[9] Bit[8] Rsv Rsv Rsv Rsv Rsv BIDIROE Rsv SPC0 Bit[7:3] and Bit[1:0] are not implemented (reads or writes to these bits are not implemented). They are reserved for future use. After system reset the following register bits are set to the default values. Table 7: SPICR2 Bits 0x00[15:8] Bits Type Description Default Value Bit[8] R/W SPC0: Serial pin control bit 0. With the MSTR control bit, this bit enables bidirectional pin configurations as shown in Table 8. Bit[9] - N/A 0 Bit[10] R/W Table 5: SPICR1 Bits (Continued) 0x00[7:0] Bits Type Description Default Value BIDIROE: Output enable in the bidirectional mode. This bit along with the MSTR bit of SPCR1 is used to enable the output buffer when the SPI is configured in the bidirectional mode. 1 = Output buffer enabled. 0 = Output buffer disabled. Bit[11] - N/A 0 Bit[12] - N/A 0 Bit[13] - N/A 0 Bit[14] - N/A 0 Bit[15] - N/A 0 0 0 0 0 6 www.quicklogic.com 2008 QuickLogic Corporation

Table 8: Bidirectional Pin Configurations Ports Description Master Normal Bidir. SCK Synchronization clock to the Slave Out Out MOSI Master Out, Slave In Out INOUT MISO Master In, Slave Out In Not Used SS_bar Slave Select signal Out Out Register: SPIBR (Offset 0x00, Byte 2) This is a Read/Write register and controls the baud rate of the SPI system. Table 9: SPI Baud Rate Register (SPIBR) Bit[23] Bit[22] Bit[21] Bit[20] Bit[19] Bit[18] Bit[17] Bit[16] Rsv SPPR2 SPPR1 SPPR0 Rsv SPR2 SPR1 SPR0 Bit 7 and bit 3 are not implemented (reads or writes to these bits are not implemented). They are reserved for future use. Before using the SPI Host Controller, these register bits must be set to the appropriate values. Table 10: SPIBR Bits 0x00[23:16] Bits Type Description Default Value Bit[16] R/W SPR0: SPI Baud Pre-selection bit 0 0 Bit[17] R/W SPR1: SPI Baud Pre-selection bit 1 0 Bit[18] R/W SPR2: SPI Baud Pre-selection bit 2 0 Bit[19] - N/A 0 Bit[20] R/W SPPR0: SPI Baud selection bit 0 0 Bit[21] R/W SPPR1: SPI Baud selection bit 1 0 Bit[22] R/W SPPR2: SPI Baud selection bit 2 0 Bit[23] - N/A 0 The Baud Rate divisor can be calculated using the following formula: Baud Rate Divisor = (SPPR + 1). (SPR + 1) 2 Baud Rate = Bus clock/ Baud Rate Divisor 2008 QuickLogic Corporation www.quicklogic.com 7

Register: SPISR (Offset 0x00, Byte 3) This read only register contains the transmit empty flag indicating there is room in the transmit data buffer. Table 11: SPI Status Register (SPISR) Bit[31] Bit[30] Bit[29] Bit[28] Bit[27] Bit[26] Bit[25] Bit[24] Rsv Rsv SPTEF Rsv Rsv Rsv Rsv Rsv Offset 0x04 Unused (Reserved) Table 12: SPISR Bits 0x00[31:24] Bits Type Description Default Value Bit[24] - N/A 0 Bit[25] - N/A 0 Bit[26] - N/A 0 Bit[27] - N/A 0 Bit[28] - N/A 0 Bit[29] R/W SPTEF: SPI transmit empty flag 0 Bit[30] - N/A 0 Bit[31] - N/A 0 This register is not implemented and is reserved for future use. Table 13: Unused Register (0x04) Byte 3 Byte 2 Byte 1 Byte 0 UNUSED (Reserved) Preamble Register (Offset 0x08) This 4-byte optional Preamble register can be a combination of the opcode and the address bytes; depending on the application and the SPI slave protocol, other formats can be used as well. Table 14: Preamble Register Preamble Byte 3 Preamble Byte 2 Preamble Byte 1 Preamble Byte 0 SPI Transfer Register (Offset 0x0C) This register contains the bit to start/stop a transaction and indicates whether it is a read or write transaction. It also consists of the preamble register byte enables and the number of data bytes to be transmitted or received. Table 15: SPI Transfer Register (SPITR) SPI Transfer Register BE[4] BE[3] BE[2] BE[1] DATA BYTES [15:3] R W S/Sp 8 www.quicklogic.com 2008 QuickLogic Corporation

Table 16: SPITR Bits 0x00[31:0] Bits Description Default Value Bit[0] S/Sp: Start/Stop a transaction. 0 Bit[1] W: Performs a write transaction 0 Bit[2] R: Performs a read transaction 0 Bit[15:3] data_bytes: Number of data bytes to be transmitted/received 0 Bit[16] BE[1]: First byte enable of the preamble register 0 Bit[17] BE [2]: Second byte enable of the preamble register 0 Bit[18] BE [3]: Third byte enable of the preamble register 0 Bit[19] BE[4]: Fourth byte enable of the preamble register 0 Bit[31:20] N/A 0 SPI Interrupt Register (Offset 0X10) This SPI Interrupt Register (SPIIR) contains Interrupt Flags, indicating the completion of transactions. The three types of interrupt flags include: Read Interrupt indicates a read transaction has been completed Write Interrupt indicates a write transaction has been completed Preamble Interrupt indicates all preamble bytes have been sent Table 17: SPI Interrupt Register Interrupt Register Rsv IP IW IR Table 18: SPIIR Bits 0x00[31:0] Bits Type Description Default Value Bit[0] RO IR: Interrupt flag that indicates read is done 0 Bit[1] RO IW: Interrupt flag that indicates write is done 0 Bit[2] RO IP: Interrupt flag the indicates preamble is done 0 Bit[31:3] - N/A 0 Slave Select Register (Offset 0x14) The SPI slave select register can be used to communicate with up to eight slave devices by setting the corresponding bit. This register configures which slave is selected during a transaction. Table 19: SPI Slave Select Register Slave Select Register S7 S6 S5 S4 S3 S2 S1 S0 2008 QuickLogic Corporation www.quicklogic.com 9

Table 20: SPI Slave Select Register Bits 0x00[31:0] Bits Description Default Value Bit[0] S0: Slave 1 select bit 0 Bit[1] S1: Slave 2 select bit 0 Bit[2] S2: Slave 3 select bit 0 Bit[3] S3: Slave 4 select bit 0 Bit[4] S4: Slave 5 select bit 0 Bit[5] S5: Slave 6 select bit 0 Bit[6] S6: Slave 7 select bit 0 Bit[7] S7: Slave 8 select bit 0 Bit[31:8] N/A 0 Functional Description Figure 2 illustrates the data transmission mechanism between the Master and Slave. Figure 2: Master/Slave Block Diagram Write FIFO 8-bits 0 1 2 3 4 5 6 7 MISO Read FIFO 8-bits Baud Generator Master MOSI SCK SS_bar 0 1 2 3 4 5 6 7 Slave 10 www.quicklogic.com 2008 QuickLogic Corporation

Table 21 shows the various modes of configurations for the SPI Host Controller. Table 21: SPI Pin Configurations Ports Description Master Normal Bidir. SCK Synchronization clock to the Slave Out Out MOSI Master Out, Slave In Out INOUT MISO Master In, Slave Out In Not Used SS_bar Slave Select signal Out Out Phase and Polarity The clock polarity control bit CPOL SPICR1 (offset 0x00, Byte0, bit[3]) and the clock phase control bit CPHA SPICR1 (offset 0x00, byte0, bit2) in the SPI Configuration Register selects one of the four possible clock modes listed in Table 22. The combination of phase and polarity is referred to as a mode. Table 22: SPI Modes a Mode CPOL CPHA Description 1 0 0 SCK idles low, data latched on the clock's rising edge and shifted on the falling edge. 2 0 1 SCK idles low, data latched on the clock's falling edge and shifted on the rising edge. 3 1 0 SCK idles high, data latched on the clock's falling edge and shifted on the falling edge. 4 1 1 SCK idles high, data latched on the clock's rising edge and shifted on the rising edge. a. For a description of the CPOL and CPHA bits, see Table 5. Figure 3 shows the waveform of a SPI transfer when CPOL = 1 and CPHA = 0. SCK idles high and data is latched on the first edge of SCK. 2008 QuickLogic Corporation www.quicklogic.com 11

Figure 3: Data Transfer with CPHA = 0 and CPOL =1 First edge of SCK Configuring SPI ports in Normal and Bidirectional Modes Refer to Table 21 for more information about modes. Normal Mode: Master configuration: Set MSTR bit (Offset Address 0x00, Byte 0, bit [4]) to 1. Set SPC0 bit (Offset Address 0x00, Byte 1, bit [0]) to 0. Set BIDIROE bit (Offset Address 0x00, Byte 1, bit [3]) to 0. Bidirectional Mode of Operation: Master configuration: Set MSTR bit (Offset Address 0x00, Byte 0, bit [4]) to 1. Set SPC0 bit (Offset Address 0x00, Byte 1, bit [0]) to 1. Set BIDIROE bit (Offset Address 0x00, Byte 1, bit [3]) to 1. SPI Host Operation This section describes the configuration and operation of the SPI Host Controller and details how the reads and writes are performed with the external slave device. Master Read Operation To perform a master read operation: 1. Set up the SPI controller by writing to the SPI configuration register (offset 0x00). NOTE: Steps a through g can be performed with a single write to address offset 0x00. a. Enable the SPI by setting the SPE bit (byte 0, bit [6]) to 1. b. Configure the SPI as a Master by setting the MSTR bit (B=byte 0, bit [4]) to 1. 12 www.quicklogic.com 2008 QuickLogic Corporation

c. Configure the shift-out direction by setting the LSBFE bit (byte 0, bit [0]): If data is to be transferred least significant bit first, set LSBFE to 1 If data is to be transferred most significant bit first, set LSBFE to 0 d. Program the baud rate bits in SPIBR (Offset Address 0x00, Byte 2). Refer to Register Descriptions on page 5. e. Set the SPI clock phase (CPHA, byte 0, bit [2]) and polarity bits (CPOL, byte 0, bit [3]) to the desired setting. Refer to the Phase and Polarity on page 11. f. Enable the SPI interrupts by setting the SPIE bit (byte 0, bit [7]) to 1. g. To enable the bidirectional mode of operation, set the SPC0 bit (byte 1, bit [0]) to 1 and the BIDIROE bit (byte 1, bit [3]) to a 1. For normal mode, set both the bits to 0. 2. If applicable, write to the preamble register (offset 0x08) with the desired opcode/address. 3. Select an external slave by asserting the corresponding bit in the Slave Select Register (offset 0x14). For example, to select the slave device connected to the SS_bar [7], set the S7 bit (byte 0, bit [8]) to 1. 4. Start data transfer by writing to the SPI Transfer Register (offset 0x0C). NOTE: Steps a through d can be performed with a single write to address offset 0x0C. a. For a read operation, set the W bit (byte 0, bit [1]) to 0 and the R bit (byte 0, bit [2]) to 1. b. Set the preamble register byte enable bits by setting the corresponding BE[3:0] bits to 1. For example, if the two most significant bytes of the preamble register are to be transmitted, set BE[3:2] (byte 2, bit [3:2]) to 11. If no preamble bytes are required, set BE[3:0] to 0000. c. Configure the number of bytes to be received by setting data_bytes[15:3] to the appropriate value. For example, to read 10 bytes, the value of data_bytes[15:3] should be 0000000001010. d. To start the read process, set the S/Sp bit (byte 0, bit [0]) to 1. 5. After the read transaction is completed (i.e., the desired number of data bytes have been received 10 bytes for the above example) and put in the receive FIFO, the SPI controller generates an interrupt signal to the processor, IR (offset 0x10, byte 0, bit 0). NOTE: This interrupt signal automatically clears the S/Sp bit (byte 0, bit [0]) to 0. a. To acknowledge the interrupt, the processor must read the SPI interrupt register (offset 0x100) to clear the read interrupt flag. b. The processor must then transfer all data from the receive FIFO by reading data_bytes[15:3] number of bytes from the Read_FIFO_Port (offset 0x1C). 2008 QuickLogic Corporation www.quicklogic.com 13

Figure 4: Master Read Operation Preamble Bytes Read Data Master Write Operation To perform a Master Write Operation: 1. Set up the SPI controller by writing to the SPI configuration register (offset 0x00). NOTE: Steps a through g can be performed with a single write to address offset 0x00. a. Enable the SPI by setting the SPE bit (byte 0, bit [6]) to 1. b. Configure the SPI as a Master by setting the MSTR bit (byte 0, bit [4]) to 1. c. Configure the shift-out direction by setting the LSBFE bit (byte 0, bit [0]). If data is to be transferred least significant bit first, set LSBFE to 1 If data is to be transferred most significant bit first, set LSBFE to 0 d. Program the baud rate bits in SPIBR (Offset Address 0x00, Byte 2). Refer to the Register Descriptions on page 5. e. Set the SPI clock phase (CPHA, byte 0, bit [2]) and polarity bits (CPOL, byte 0, bit [3]). Refer to the Phase and Polarity on page 11. f. Enable the SPI interrupts by setting the SPIE bit (byte 0, bit [7]) to 1. g. To enable the bidirectional mode of operation, set the SPC0 bit (byte 1, bit [0]) to 1 and the BIDIROE bit (byte 1, bit [3]) to 1. For normal mode, set both the bits to 0. 2. If applicable, write to the optional preamble register (offset 0x08) with the desired Opcode/Address. 3. An external Slave must be selected by asserting the corresponding bit in the Slave Select Register (offset 0x14). a. Set the corresponding slave bit to 1 to select the external slave device. For example, to select the slave device connected to the SS_bar [7], set the S7 bit (byte 0, bit [8]) to 1. 4. Write all the data bytes to be transmitted to the WRITE FIFO PORT (offset 0x18). For example, to transmit eight bytes of data, the WRITE FIFO PORT is written to twice. 5. Start data transfer by writing to the SPI Transfer Register (offset 0x0C). NOTE: Steps a through d can be performed with a single write to address offset 0x0C. 14 www.quicklogic.com 2008 QuickLogic Corporation

a. For a write operation, set the W bit (byte 0, bit [1]) to 1 and the R bit (byte 0, bit [2]) to 0. b. Set the preamble register byte enable bits by setting the corresponding BE [3:0] bits to 1. For example, if the two most significant bytes of the preamble register are to be transmitted, set BE [3:2] (byte 2, bit [3:2]) to 11. If no preamble bytes are required, set BE [3:0] to 0000. c. Configure the number of bytes to be transmitted by setting data_bytes[15:3] to the appropriate value. For example, to write 10 bytes, the value of data_bytes[15:3] should be 0000000001010. d. To start the write process, set the S/Sp bit (byte 0, bit [0]) to 1. 6. After the write transaction is completed, (i.e., the desired number of data bytes have been transmitted 10 bytes for the above example), the SPI controller generates an interrupt signal to the processor, IW (offset 0x10, byte 0, bit 0). NOTE: This interrupt signal also automatically clears the S/Sp bit (byte 0, bit [0]) to 0. To acknowledge the interrupt, the processor must read the SPI interrupt register (offset 0x100) to clear the write interrupt flag. Figure 5: Master Write Operation Preamble Bytes Write Data Supported Operating Systems The SPI Host Controller Proven System Block (PSB) supports the following operating systems: Windows CE Windows Mobile Linux 2008 QuickLogic Corporation www.quicklogic.com 15

Contact Information Phone: (408) 990-4000 (US) (905) 940-4149 (Canada) +(44) 1932-57-9011 (Europe) +(852) 2297-2297 (Asia) E-mail: info@quicklogic.com Sales: www.quicklogic.com/sales Support: www.quicklogic.com/support Internet: www.quicklogic.com Revision History Revision Date Originator and Comments A March 2008 Tina Durgia and Kathleen Murchek Notice of Disclaimer QuickLogic is providing this design, product or intellectual property "as is." By providing the design, product or intellectual property as one possible implementation of your desired system-level feature, application, or standard, QuickLogic makes no representation that this implementation is free from any claims of infringement and any implied warranties of merchantability or fitness for a particular purpose. You are responsible for obtaining any rights you may require for your system implementation. QuickLogic shall not be liable for any damages arising out of or in connection with the use of the design, product or intellectual property including liability for lost profit, business interruption, or any other damages whatsoever. QuickLogic products are not designed for use in life-support equipment or applications that would cause a life-threatening situation if any such products failed. Do not use QuickLogic products in these types of equipment or applications. QuickLogic does not assume any liability for errors which may appear in this document. However, QuickLogic attempts to notify customers of such errors. QuickLogic retains the right to make changes to either the documentation, specification, or product without notice. Verify with QuickLogic that you have the latest specifications before finalizing a product design. Copyright and Trademark Information Copyright 2008 QuickLogic Corporation. All Rights Reserved. The information contained in this document and is protected by copyright. All rights are reserved by QuickLogic Corporation. QuickLogic Corporation reserves the right to modify this document without any obligation to notify any person or entity of such revision. Copying, duplicating, selling, or otherwise distributing any part of this product without the prior written consent of an authorized representative of QuickLogic is prohibited. QuickLogic is a registered trademark, and the QuickLogic logo is a trademark of QuickLogic Corporation. All other trademarks are owned by their respective companies. 16 www.quicklogic.com 2008 QuickLogic Corporation