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

Similar documents
For reference only Refer to the latest documents for details

spi 1 Fri Oct 13 13:04:

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

Serial Peripheral Interface (SPI)

Universität Dortmund. IO and Peripheral Interfaces

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

Design with Microprocessors

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

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

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

SPI Block User Guide V02.07

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

Menu. What is SPI? EEL 3744 EEL 3744 SPI

Serial Communication. Simplex Half-Duplex Duplex

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

Serial Communication. Spring, 2018 Prof. Jungkeun Park

Serial Communications

Basics of UART Communication

Serial Peripheral Interface (SPI) Host Controller Data Sheet

or between microcontrollers)

EE 354 November 13, 2017 ARM UART Notes

Amarjeet Singh. January 30, 2012

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

EE 308: Microcontrollers

EE 308 Spring Using the 9S12 SPI

Informatics for industrial applications

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

Using the Z8051 MCU s USI Peripheral as an SPI Interface

Understanding SPI with Precision Data Converters

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

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

Interfacing Techniques in Embedded Systems

Concepts of Serial Communication

Communication. Chirag Sangani

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

Serial Buses in Industrial and Automotive Applications

SPI 3-Wire Master (VHDL)

Raspberry Pi - I/O Interfaces

< W3150A+ / W5100 Application Note for SPI >

Module Introduction. PURPOSE: The intent of this module, is to explain several of the important features of Freescale s i.mx1 applications processor.

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

Serial Peripheral Interface (SPI)

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

Serial Communication. Simplex Half-Duplex Duplex

C8051F700 Serial Peripheral Interface (SPI) Overview

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

RL78 Serial interfaces

BLE 1.4 SPI Driver Design Version 1.x (Draft)

AN-1435 APPLICATION NOTE

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

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

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

Real-Time Embedded Systems. CpE-450 Spring 06

Hello, and welcome to this presentation of the STM32 I²C interface. It covers the main features of this communication interface, which is widely used

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

Serial Peripheral Interface Bus SPI

Serial Peripheral Interface (SPI)

Emulating Dual SPI Using FlexIO

Synchronous = SPI (3 options)

Serial Communication

Microcontrollers and Interfacing

ECE 4510/5530 Microcontroller Applications Week 6

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

The SPI supports data bus widths of 32 bits.

Growing Together Globally Serial Communication Design In Embedded System

Serial Communication Prof. James L. Frankel Harvard University. Version of 2:30 PM 6-Oct-2015 Copyright 2015 James L. Frankel. All rights reserved.

Chapter 10 Sections 1,2,9,10 Dr. Iyad Jafar

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

CprE 488 Embedded Systems Design. Lecture 4 Interfacing Technologies

Using FlexIO to emulate communications and timing peripherals

SPI Framework Module Guide

PIC32 Family Reference Manual

BUS TIMING ANALYSIS. George E Hadley, Timothy Rogers, and David G Meyer 2018, Images Property of their Respective Owners

AN Multifunction Serial Interface of FM MCU. Contents. 1 Introduction

Device: MOD This document Version: 1.0. Matches module version: v3 [29 June 2016] Date: 23 October 2017

NS9360. Errata _F. Release date: March 2008

COMP2121: Microprocessors and Interfacing

MCS-51 Serial Port A T 8 9 C 5 2 1

SPI Controller. Features of the SPI Controller. SPI Block Diagram and System Integration

Digital Storage Oscilloscope

NS9750B-0. Use in conjunction with: Errata , Rev G. Release date: May Phone: Web:

Welcome to this presentation of the STM32 direct memory access controller (DMA). It covers the main features of this module, which is widely used to

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

Serial versus Parallel Data Transfers

Unit 19 - Serial Communications 19.1

INTRODUCTION TO FLEXIO

Parallel IO. Serial IO. Parallel vs. Serial IO. simplex vs half-duplex vs full-duplex. Wires: Full Duplex. Wires: Simplex, Half-duplex.

8051 Serial Communication

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

Lecture 14 Serial Peripheral Interface

Application Note AN_289. FT51A Programming Guide

AREA OPTIMIZATION OF SPI MODULE USING VERILOG HDL

Design Development and Implementation of SPI

ECE 4510 Introduction to Microprocessors. Chapter 10

STM32F030x4/x6/x8/xC Errata sheet

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

UART TO SPI SPECIFICATION

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

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

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

Transcription:

SERIAL PERIPHERAL INTERFACE (SPI) George E Hadley, Timothy Rogers, and David G Meyer 2018, Images Property of their Respective Owners

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

SPI THEORY Motivation USART can be used for asynchronous serial communication between two devices Question: Are there alternatives? Answer: Consider the concept of synchronous serial communication Synchronous serial communication is similar to asynchronous serial communication, except the devices share a common clock signal Advantages: Higher communication speeds (8-16x oversampling of signal not required, start/stop bits not required, packets can vary in length) Disadvantages: Hard to transmit data over long distances (signal integrity issues); SPI generally limited to board-level communication and short cable runs

SPI THEORY Masters and Slaves Serial Peripheral Interface (SPI) peripherals utilize the concept of master and slave devices to moderate communications Master: Initiates sending data or requests that data be sent (only one device may be master in traditional SPI protocols); also supplies the clocking signal Slave: Responds to those requests (can be multiple slave devices within system) Based on these roles, SPI peripherals commonly feature the following lines: Master Out/Slave In (MOSI): transmitting data (master) or receiving data (slave) Master In/Slave Out (MISO): receiving data (master) or transmitting data (slave) SPI System Clock (SCK): Shared clock for synchronous data transfer Slave Select (SSx): One or more (optional) control signals used for differentiating among multiple slave devices

SPI THEORY SPI Structure Single Slave SS SPI feature: Data is transferred simultaneously between master and slave devices

SPI THEORY SPI Structure Multiple Slaves Here, the slave select signals are provided by GPIO pins

SPI THEORY SPI Communications and Errors SPI Communication Structure: SPI Communication Errors: Overrun Error: Data is received by a master or slave device before previous received data has been read

STM32F0 SPI Resources Course microcontroller features two SPI peripherals: Default mode of operation is Motorola SPI Integrated I 2 S functionality (option for high quality stereo audio interface using an external CODEC) Master or slave operation 4-16 bit programmable frame size Multi-master mode capability Interrupt capability and DMA operation

STM32F0 SPI Subsystem Overview

Basic Configuration for Full Duplex Operation (Single Master, Single Slave) Here, the assertion or negation of the NSS pin indicates master or slave operating mode

Simplex Single Master/Single Slave Application Here, data is only transferred one direction: from the master to the salve (master is transmitonly, slave is receive-only)

Half-Duplex Single Master/Single Slave Application Here, the direction of (half-duplex) communication can be changed; master remains the clocking source

Multiple Independent Slaves Here, the NSS input of each slave is used to select (enable) it; the slave select outputs of the master are generated by GPIO pins

NSS Pin Logic If the SPI is configured for master mode and the NSS input is low (Vss), then an error is flagged

Clock Mode Phase/Polarity The combination of clock phase (CPHA) and clock polarity (CPOL) settings determine how the serial data stream is sampled The SPI clock divisor is 2 (1+BR[2:0])

COLLABORATIVE CLICKER QUIZ (CCQ) Question 1 1. The synchronous aspect of an SPI interface means: A. data can only be transmitted in one direction B. data can be transmitted in both directions, but not at the same time C. data can be transmitted in both directions simultaneously D. data transmission requires an accompanying clock signal E. none of the above

COLLABORATIVE CLICKER QUIZ (CCQ) Question 2 2. The minimum SPI clock divisor possible is: A. 1 B. 2 C. 4 D. 8 E. none of the above

COLLABORATIVE CLICKER QUIZ (CCQ) Question 3 3. Based on a 48 MHz system clock, the maximum SPI data transfer rate possible (in bits/second) is: A. 6,000,000 bps B. 8,000,000 bps C. 12,000,000 bps D. 24,000,000 bps E. none of the above

COLLABORATIVE CLICKER QUIZ (CCQ) Question 4 2. The maximum SPI clock divisor possible is: A. 128 B. 256 C. 512 D. 1024 E. none of the above

COLLABORATIVE CLICKER QUIZ (CCQ) Question 5 3. Based on a 48 MHz system clock, the minimum SPI data transfer rate possible (in bits/second) is: A. 46,875 bps B. 93,750 bps C. 187,500 bps D. 375,000 bps E. none of the above

Clock Mode Phase/Polarity Clock format for CPHA = 0 and CPOL = 0 ( sample data on odd-numbered positive clock edges )

Clock Mode Phase/Polarity These are all the permutations possible with clock phase and polarity control note that the bit order can be programmed as well (i.e., MSB first or LSB first) The reason all these different modes are provided is due to the wide variety of SPI compatible devices on the market

Data Alignment Data alignment when data length is not equal to 8-bit or 16-bit the minimum data length is 4 bits

Data Packing Illustration of data packing in FIFO for transmission and reception

STM32F0 SPI Registers SPI Control Register 1 (SPIx_CR1): Control and configuration information for the SPI peripheral Significant Fields: Frame Format (LSBFirst): Indicates endianness of SPI SPI Enable (SPE): Enables/disables SPI peripheral Baud Rate Control (BR[2:0]): SPI clock divisor Master Selection (MSTR): Specifies master or slave mode

STM32F0 SPI Registers SPI Control Register 2 (SPIx_CR2): More control and configuration information for the SPI peripheral Significant Fields: Data Size (DS[3:0]): Sets SPI frame size (4-16 bits) TX Interrupt Enable (TXEIE): Enable for TX interrupt RX Interrupt Enable (RXNEIE): Enable for RX interrupt SS Output Enable: Used to enable/disable SPI operation in a multi-master environment

STM32F0 SPI Registers SPI Status Register (SPIx_SR): More control and configuration information for the SPI peripheral Significant Fields: Busy Flag (BSY): Indicates if SPI peripheral is in use Overrun Flag (OVR): Indicates FIFO overrun Underrun Flag (UDR): Indicates FIFO underrun TX Buffer Empty (TXE): Indicates transmitter is free RX Buffer Not Empty (RXNE): Indicates data is available

STM32F0 SPI Registers Other SPI Registers: SPI Data Register (SPIx_DR): Contains data to be received or transmitted (RX data and TX data contained in separate FIFOs, both accessed through this register) SPI CRC Registers (SPIx_CRCPR, SPIx_RXCRCR, SPIx_TXCRCR): Registers used for cyclic redundancy checking (CRC), a more advanced form of error checking compared to USART parity checking

SPI APPLICATION Basic Initialization The master or slave configuration steps are nearly identical outlined here are the basic steps for standard communication

SPI APPLICATION Constant Current LED Driver Use of constant current LED drivers eliminates the need for current limiting resistors many of the ICs designed for this purpose utilize an SPI compatible (simplex) interface The output enable (OE ) input can be driven by a PWM output to control LED intensity The latch enable (LE) input is used to control when the display is updated (asserted after new data is shifted in)

Questions?