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

Similar documents
spi 1 Fri Oct 13 13:04:

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

Serial Peripheral Interface (SPI)

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

Understanding SPI with Precision Data Converters

Menu. What is SPI? EEL 3744 EEL 3744 SPI

EE 308 Spring Using the 9S12 SPI

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

Design with Microprocessors

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

LAB4. Program the on chip SPI module

EE 308: Microcontrollers

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

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

SPI 3-Wire Master (VHDL)

Microcontrollers and Interfacing

SPI: Serial Peripheral Interface

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

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

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

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

Serial Peripheral Interface (SPI)

SPI Block User Guide V02.07

Raspberry Pi - I/O Interfaces

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

Using the Z8051 MCU s USI Peripheral as an SPI Interface

Lecture 14 Serial Peripheral Interface

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

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.

C8051F700 Serial Peripheral Interface (SPI) Overview

Real Time Embedded Systems. Lecture 1 January 17, 2012

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

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

Amarjeet Singh. January 30, 2012

Serial Peripheral Interface (SPI) Host Controller Data Sheet

DS1306. Serial Alarm Real Time Clock (RTC)

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

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

< W3150A+ / W5100 Application Note for SPI >

Introduction to I2C & SPI. Chapter 22

Serial Communication. Spring, 2018 Prof. Jungkeun Park

Universität Dortmund. IO and Peripheral Interfaces

SPI (Serial & Peripheral Interface)

SPI bus communication with LDE/LME pressure sensors

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

Growing Together Globally Serial Communication Design In Embedded System

Serial Communication. Simplex Half-Duplex Duplex

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

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

Design Development and Implementation of SPI

Introducing SPI Xpress SPI protocol Master / Analyser on USB

ECE 471 Embedded Systems Lecture 20

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

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

DS1305 Serial Alarm Real Time Clock (RTC)

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

PIN ASSIGNMENT PIN DESCRIPTION

UART TO SPI SPECIFICATION

FPGA Implementation Of SPI To I2C Bridge

Serial communications with SPI

Serial Buses in Industrial and Automotive Applications

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

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

PARALLEL COMMUNICATIONS

Lecture 25 March 23, 2012 Introduction to Serial Communications

Mbed Microcontroller SPI. Spring, 2018 Prof. Jungkeun Park

For reference only Refer to the latest documents for details

Serial versus Parallel Data Transfers

ArduCAM-M-2MP Camera Shield

Real-Time Embedded Systems. CpE-450 Spring 06

Serial Communications

Interfacing Techniques in Embedded Systems

Introduction the Serial Communications Huang Sections 9.2, 10.2 SCI Block User Guide SPI Block User Guide

ECE 4510/5530 Microcontroller Applications Week 6

Serial Peripheral Interface (SPI)

DS1305. Serial Alarm Real Time Clock (RTC) FEATURES PIN ASSIGNMENT ORDERING INFORMATION

Marten van Dijk Department of Electrical & Computer Engineering University of Connecticut

Part 1 Using Serial EEPROMs

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

DISCONTINUED. SPI Communication with AMT bit Absolute Encoder

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

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

AREA OPTIMIZATION OF SPI MODULE USING VERILOG HDL

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

High Speed SPI Slave Implementation in FPGA using Verilog HDL

11.4 THE SERIAL PERIPHERAL INTERFACE (SPI)

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

Section 16. Basic Sychronous Serial Port (BSSP)

or between microcontrollers)

LABORATORIO DI ARCHITETTURE E PROGRAMMAZIONE DEI SISTEMI ELETTRONICI INDUSTRIALI. Laboratory Lesson 9: Serial Peripheral Interface (SPI)

Synchronous = SPI (3 options)

Marten van Dijk, Syed Kamran Haider

LCD H C 1 2 GP2D PP4 MISO MOSI DIN DOUT SCK PP5 SCK D0 D1 D2 D3 D4 D5 D6 D7 DIN. Maximum SCK = 500 khz SCK D0 D1 D2 D3 D4 D5 D6 D7 DOUT

SPI Universal Serial Communication Interface SPI Mode

Implementation of MCU Invariant I2C Slave Driver Using Bit Banging

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

PIC Serial Peripheral Interface (SPI) to Digital Pot

LB5900 Series Power Sensor SPI & I2C Interface Guide

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

The Serial Peripheral Interface

Transcription:

EE 456 Fall, 2009 Notes on SPI Bus Blandford/Mitchell The Serial Peripheral Interface (SPI) bus was created by Motorola and has become a defacto standard on many microcontrollers. This is a four wire bus and always transmits data in full duplex mode. Unlike the RS-232 bus and the USB bus, the SPI bus is synchronous so that a clock is sent along with the data. In the simplest mode of operation the SPI bus facilitates communication between a master and a slave module. The master module initiates the transmission and for every bit transmitted a corresponding bit must be received. The individual modules determine whether or not both bits are needed and are free to discard either. For transmission only, the master transmits a bit but the slave must transmit a dummy reply bit. There are four signals on the SPI bus as shown in Table 1. If there is only one slave device in the system the SS pin may be tied low making this a 3-wire system. (On some devices which implement this interface, such as some A to D converters, a falling edge is required on SS.) Typically, the MISO line from the slave is in a tri-state mode and is only active when the slave is activated. This permits multiple slaves to share a common MISO line. SCLK MOSI MISO SS ( or SS ) Serial Clock (from the master) Master Out, Slave In (from the master) Master In, Slave Out (from the slave) Slave Select (from the master and active low) Table 1 SPI bus signals. To transmit data the master must be running a clock which can go from 1MHz to 70MHz. The master begins transmission by pulling the SS line low for the slave. The master then sends a bit on the MOSI line which the slave can read. The slave then sends a bit on the MISO line which the master can read. Typically the master and slave have shift registers each of which stores one word but there is no standard word length. Figure 1 SPI Bus exchange of information between a master and a slave. There are two SPI configuration signals that must be set up by the user. These two signals have to do with the clock polarity and the clock phase. They are called CPOL and CPHA. CPOL defines the default state of the clock signal in the idle state. These states are defined in Table 2. The critical factor is that the master and slave must have CPOL and CPHA in the same state.

Mode CPOL CPHA 0 0 0 Data clocked on rising edge and data can change on the falling edge 1 0 1 Data clocked on the falling edge and data can be changed on the rising edge 2 1 0 Data clocked on the falling edge and data can be changed on the rising edge 3 1 1 Data clocked on rising edge and data can change on the falling edge Table 2 Mode definitions for signal polarity on the SPI bus. Philips P89LPC916 Figure 2 shows the logic diagram for the LPC916 which implements a 4-wire version of the SPI interface. Many of the pins on the LPC916 are multiplexed to serve multiple functions. The pin diagrams are shown in Figure 3. Figure 2 The P89CLPC916 logic diagram. Figure 3 Pin assignments and packaging for the LPC916.

Note that the LPC916 also has a 4-input multiplexed 8-bit A/D converter, a single DAC output (also 8-bit), 2K of flash program memory, and operates from 2.4 to 3.6 volts with 5 volt tolerant I/O pins. Figure 4 shows the SPI interface logic and pin connections which are multiplexed with pins from Port 2. To configure the SPI channel you need to assign values to the bits in the SPI Control register in Figure 5. In addition to CPOL and CPHA, there is an SPEN bits which enables the channel (SPEN = 1 to enable), a MSTR bit to determine if this module is a master (set to 1) or a slave (set to 0), plus two bits to set the clock rate. SPR1-SPR0 = 00(divide by 4), 01 (divide by 16), 10 (divide by 64) or 11 (divide by 128). The signal SSIG must be set to 0 if the SS line is going to be ignored (3-wire interface). In addition, the DORD bit determines the order in which the data is sent (1 = LSB first, 0 = MSB first). This implementation has a SPI status register which has a "Finished" bit named SPIF. This bit is set to 1 when serial transmission finishes and can be used to generate an interrupt (Interrupt 9 at 0x4B). Note that the transmission complete flag also indicates that a byte has been received since every bit is sent in full duplex mode. Figure 4 The LPC916 SPI logical interface. Figure 5 The SPI Control register (SPCTL). None of the bits in this register are bit addressable.

In addition to the SPCTL register, there are two other registers which are needed to make full use of the SPI interface: SPSTAT is the SPI Status register and SPDATA is the SPI data register. The SPSTAT register has just two bits: SPIF is the transfer completion flag which is set to 1 when the present data byte has been transferred. It must be cleared by software and curiously, this is done by writing a one to this bit. WCOL is the write collision indicator. This bit is set if the user attempts to write to the SPDATA register before the transfer is complete. This bit too must be cleared by software by writing a 1 to the bit. The SPDATA register is an 8-bit register that holds the data to be transferred. The user can write and read this register. The program on the following page can be executed on a P89LPC916. The device is set as a master and the bit pattern 0x55 is sent out along with the clock to the SPI port.

/* SPISftWrPrj.c * This program runs on a P89LPC916. It sets the processor * up as an SPI master and transmits the bit pattern * 0101 01010 out on the SPI port. */ #include<reg916.h> void InitializeSPI(void); void main(void) {InitializeSPI(); SPSTAT = 0x80; //Clear transfer complete flag while(1) {SPDAT = 0x55; //Send out 0101 0101 while(!(spstat & 0x80)); //Wait for transfer completion SPSTAT = 0x80; //Cleaer transfer complete flag void InitializeSPI() {SPCTL = 0x54; //use SS, Enable, LSB first, Master, CPOL/CPHA = 01, CClk/4