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

Similar documents
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

LED1 LED2. Capacitive Touch Sense Controller LED3 LED4

I 2 C Slave Controller. I 2 C Master o_timeout_intr

ice40lm Barcode Emulation Solution Control Registers and Data Buffer

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

I 2 C Master Control FSM. I 2 C Bus Control FSM. I 2 C Master Controller

Reference Design RD1065

ice40 Ultra Self-Learning IR Remote User s Guide

8b/10b Encoder/Decoder

SPI 3-Wire Master (VHDL)

Understanding SPI with Precision Data Converters

Level Shifter. for. Hardware User s Manual.

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

FPGA Implementation Of SPI To I2C Bridge

MDIO Master and Slave Controllers

BSCAN2 Multiple Scan Port Linker

IDE/ATA Interface Controller with WISHBONE

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

UART TO SPI SPECIFICATION

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

Block Diagram. mast_sel. mast_inst. mast_data. mast_val mast_rdy. clk. slv_sel. slv_inst. slv_data. slv_val slv_rdy. rfifo_depth_log2.

LatticeECP2/M Soft Error Detection (SED) Usage Guide

Serial Peripheral Interface. What is it? Basic SPI. Capabilities. Protocol. Pros and Cons. Uses

Serial Peripheral Interface (SPI) Host Controller Data Sheet

Design Development and Implementation of SPI

Enhanced Closed-loop Trim with I 2 C Control for Platform Manager Devices

High Speed SPI Slave Implementation in FPGA using Verilog HDL

Using the Z8051 MCU s USI Peripheral as an SPI Interface

spi 1 Fri Oct 13 13:04:

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

Color Space Converter

Amarjeet Singh. January 30, 2012

LatticeXP2 Soft Error Detection (SED) Usage Guide

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

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

RECONFIGURABLE SPI DRIVER FOR MIPS SOFT-CORE PROCESSOR USING FPGA

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

App Note Application Note: Addressing Multiple FPAAs Using a SPI Interface

Serial Peripheral Interface (SPI)

It is well understood that the minimum number of check bits required for single bit error correction is specified by the relationship: D + P P

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

LAB4. Program the on chip SPI module

< W3150A+ / W5100 Application Note for SPI >

Universität Dortmund. IO and Peripheral Interfaces

ASNTu2s PCB with Tiger Board USB to 7-Channel 3-Wire Interface Bridge Application Notes

Low-Cost Serial RapidIO to TI 6482 Digital Signal Processor Interoperability with LatticeECP3

LatticeSCM SPI4.2 Interoperability with PMC-Sierra PM3388

Serial Communication. Spring, 2018 Prof. Jungkeun Park

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

Serial Communication. Simplex Half-Duplex Duplex

Scalable Low-Voltage Signaling with LatticeSC/M Devices

Raspberry Pi - I/O Interfaces

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

Parallel to MIPI CSI-2 TX Bridge

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

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

Lecture 25 March 23, 2012 Introduction to Serial Communications

AN10428 UART-SPI Gateway for Philips SPI slave bridges

AN510 Using SPI protocol with pressure sensor modules

Serial Peripheral Interface (SPI)

Introduction to I2C & SPI. Chapter 22

From Datasheets to Digital Logic. synthesizing an FPGA SPI slave from the gates

Microcontrollers and Interfacing

Introduction the Serial Communications Parallel Communications Parallel Communications with Handshaking Serial Communications

Interfacing Techniques in Embedded Systems

Parallel Data Transfer. Suppose you need to transfer data from one HCS12 to another. How can you do this?

LatticeXP2 Dual Boot Usage Guide

MachXO2 Low Power Control Demo User s Guide

Design with Microprocessors

ISSN Vol.03,Issue.29 October-2014, Pages:

ArduCAM-M-2MP Camera Shield

International Journal of Advance Engineering and Research Development DESIGN AND IMPLEMENTATION OF SPI PROTOCOL

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

Real-Time Embedded Systems. CpE-450 Spring 06

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

SPI Protocol of the TLE941xy family

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

LatticeECP2/M Density Migration

Introducing SPI Xpress SPI protocol Master / Analyser on USB

Introduction. Serial Peripheral Interface (SPI) SPI Basics. Capabilities of SPI

Gamma Corrector IP Core User Guide

LatticeSC MACO Core LSCDR1X18 Low-Speed Clock and Data Recovery User s Guide

Optimal Implementation Of UART_SPI Controller and Slave Interface With Master.

Powering Up and Programming the ProcessorPM isppac-powr605

SPI Block User Guide V02.07

The SPI supports data bus widths of 32 bits.

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

CprE 488 Embedded Systems Design. Lecture 4 Interfacing Technologies

1.3inch OLED User Manual

PARALLEL COMMUNICATIONS

LatticeSC/M Family flexipcs Data Sheet. DS1005 Version 02.0, June 2011

Using FlexIO to emulate communications and timing peripherals

Basics of UART Communication

or between microcontrollers)

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

EECS 373 Design of Microprocessor-Based Systems

Median Filter IP Core User s Guide

Communication. Chirag Sangani

Tektronix DPO Demo 1 Board Instruction Manual

SPI (Serial & Peripheral Interface)

Transcription:

October 2012 Introduction Reference Design RD1142 The Serial Peripheral Interface (SPI) is used primarily for synchronous serial communication between a host processor and its peripherals. The SPI bus is often selected because of its low pin count and full-duplex mode that can achieve data throughput in the tens of Mbps range. The SPI bus uses a 4-wire interface with two unidirectional data lines to communicate between the master and the selected slave. It supports one master with multiple slaves on one bus and allows protocol flexibility for the bit transferred. This reference design implements a SPI slave device interface that provides full-duplex, synchronous, serial communication with the SPI master. The data sie of the SPI bus can be configured to either 16 or 8 bits. The SPI Slave Controller reference design supports all modes of CPOL and CPHA 00, 01, 10 and 11. This design uses three pins (clock, data in and data out) plus one select for each slave device. A SPI is a good choice for communicating with low-speed devices that are accessed intermittently and transfer data streams rather than reading and writing to specific addresses. A SPI is an especially good choice if we can take advantage of its full-duplex capability for sending and receiving data at the same time. This design is implemented in VHDL. The Lattice icecube2 Place and Route tool integrated with Synplify Pro synthesis tool is used for the implementation of the design. The design uses an ice40 ultra low density FPGA and can be targeted to other ice40 family members. Figure 1. Block Diagram i_sys_rst i_sys_clk i_mosi i_csn i_wr o_miso i_rd i_cpol SPI Master i_ssn SPI Slave i_cpha i_lsb_first i_data [15:0] Processor Interface SPI Bus Processor o_data [15:0] o_tx_ready o_rx_ready o_rx_error o_tx_error o_tx_ack o_tx_no_ack Features Supports all four modes of CPOL and CPHA operation (00/01/10/11) Supports variable data widths (8 and 16 bits) Provision for easy integration of any processor interface IP-XACT version 1.2 compliant 2012 Lattice Semiconductor Corp. All Lattice trademarks, registered trademarks, patents, and disclaimers are as listed at www.latticesemi.com/legal. All other brand or product names are trademarks or registered trademarks of their respective holders. The specifications and information herein are subject to change without notice. www.latticesemi.com 1 rd1142_01.0

Functional Description Figure 2. Functional Block Diagram i_ssn i_mosi Tx Buffer Shift Register Rx Buffer o_data[15:0] i_data [15:0] o_miso i_cpol i_cpha Control Logic i_lsb_first SPI Slave SPI Slave Receiver MOSI sampling SPI slave receives the data on the MOSI line based on CPOL and CPHA modes as follows: Sample at positive edge of SCLK for: i_cpol = 0 and i_cpha = 0 i_cpol = 1 and i_cpha = 1 Sample at negative edge of SCLK for: i_cpol = 1 and i_cpha = 0 i_cpol = 0 and i_cpha = 1 After the data is received, rx_ready goes high and valid received data is available on the bus. If new data has arrived and the last data received has not yet been read, then the rx_error signal goes high to indicate a receive error. SPI Slave Transmitter Sending data on the MISO line The SPI slave transmits the data on the MISO line from a shift register based on CPOL and CPHA as follows: CPOL = 0 and CPHA = 0: Data is placed before the rising edge of sclk CPOL = 1 and CPHA = 0: Data is placed before the falling edge of sclk CPOL = 0 and CPHA = 1: Data is placed at the rising edge of sclk CPOL = 1 and CPHA = 1: Data is placed at the falling edge of sclk At the end of data transmission, the tx_ready signal goes high. When the transmitter is busy transmitting a data stream, the tx_error signal goes high if the transmit buffer data is over-written by the processor interface. 2

Clock Requirements 3 SPI Slave Controller For proper operation of the SPI slave, the system frequency should be twice that of the SCL frequency at a minimum. Signal Descriptions Table 1. Signal Descriptions Signal Width Type Description i_csn 1 Input Active low chip select i_data 16 Input Input data from the processor interface i_wr 1 Input Active low write enable i_rd 1 Input Active high read enable o_data 16 Output Output data to processor interface. o_tx_ready 1 Output Transmitter ready status High indicates the transmitter is ready to send additional data o_rx_ready 1 Output Receiver ready High indicates the receiver is ready to receive additional data o_tx_error 1 Output Indicates error in transmission of data o_rx_error 1 Output Indicates error in reception of data i_cpol 1 Input Polarity of the clock i_cpha 1 Input Phase of the clock i_lsb_first 1 Input LSB sent first when 1. MSB goes first when 0. o_miso 1 Output Slave output to master i_mosi 1 Input Slave input from master i_ssn 1 Input Slave select from master 1 Input Serial clock from master i_sys_rst 1 Input Asynchronous active low reset i_sys_clk 1 Input System clock o_tx_ack 1 Output Transmission acknowledged from slave o_tx_no_ack 1 Output Transmission not acknowledged from slave Initialiation Conditions An asynchronous active low reset signal assertion is necessary to initialie the SPI slave to the proper operating state. Receive and transmit buffers are initialied to ero during the reset condition. Configurable Parameters DATA_SIZE This parameter configures the data width of the SPI transaction. It can take either of two values: 16 (the default value) or 8. Operation Sequence 1. Write a data slave, set up CPOL, CPHA and LSB/MSB first mode. 2. Enable the SPI slave by making i_ssn = 0. 3. Generate the SCL depending upon CPOL and CPHA. 4. Receive the data from the i_data line to the MOSI line depending upon CPOL, CPHA and LSB/MSB. 5. Similarly, drive the MISO line depending upon CPOL, CPHA and LSB/MSB. 6. Repeat steps 1, 2, 3, 4 and 5 for four different sets of CPOL, CPHA and LSB/MSB first modes and input the data pattern to the slave.

Timing Diagram Signal definitions: Serial clock line (Generated by master) i_cpol Clock polarity i_cpha Clock phase i_ssn Slave select o_miso Output from the SPI slave i_mosi Input to the SPI slave Figure 3. Timing Diagram i_cpol = 0 i_cpol = 1 o_slave_csn 0 i_cpha = 1 sclk_cycle_cou i_miso o_mosi i_cpha = 0 sclk_cycle_cou i_miso o_mosi Simulation Waveforms Figure 4. Simulation Waveforms 4

Implementation This design is implemented in VHDL. When using this design in a different device, density, speed or grade, performance and utiliation may vary. Table 2. Performance and Resource Utiliation Architecture Family Language Utiliation (LUTs) f MAX (MH) I/Os Resources ice40 1 VHDL 217 254 48 N/A 1. Performance and utiliation characteristics are generated using ice-40lp1k-cm121 with icecube2 design software. References ice40 Family Handbook Technical Support Assistance Hotline: 1-800-LATTICE (North America) +1-503-268-8001 (Outside North America) e-mail: techsupport@latticesemi.com Internet: www.latticesemi.com Revision History Date Version Change Summary October 2012 01.0 Initial release. 5