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

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

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

EE 308 Spring Using the 9S12 SPI

ECE 4510/5530 Microcontroller Applications Week 6

Serial Peripheral Interface (SPI) Host Controller Data Sheet

ECE 4510 Introduction to Microprocessors. Chapter 10

spi 1 Fri Oct 13 13:04:

Synchronous = SPI (3 options)

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

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

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

CS/ECE 5780/6780: Embedded System Design

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

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

AREA OPTIMIZATION OF SPI MODULE USING VERILOG HDL

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

EE345L Fall 2008 Final Page 1 of 12

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

Serial Peripheral Interface (SPI)

Menu. What is SPI? EEL 3744 EEL 3744 SPI

For reference only Refer to the latest documents for details

Using the Z8051 MCU s USI Peripheral as an SPI Interface

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

PARALLEL COMMUNICATIONS

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

Design with Microprocessors

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

SPI: Serial Peripheral Interface

Raspberry Pi - I/O Interfaces

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

EE 308: Microcontrollers

AN-150 HI-3598, HI-3599 Design Example Applications Note

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

Serial Communication. Simplex Half-Duplex Duplex

Universität Dortmund. IO and Peripheral Interfaces

< W3150A+ / W5100 Application Note for SPI >

SPI 3-Wire Master (VHDL)

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

Design Development and Implementation of SPI

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

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

C8051F700 Serial Peripheral Interface (SPI) Overview

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

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

Introduction to I2C & SPI. Chapter 22

Module 3.F. Serial Communications Interface (SCI) Tim Rogers 2017

Lecture 14 Serial Peripheral Interface

Serial Peripheral Interface (SPI)

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

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

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

Using the Serial Peripheral Interface (SPI) Module on 68HC(9)08 Microcontrollers

Interfacing Techniques in Embedded Systems

Serial Communication. Spring, 2018 Prof. Jungkeun Park

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

INTRODUCTION TO FLEXIO

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

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

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

EE345L Spring 2004 Final Version 3 Page 1 of 8

SPI (Serial & Peripheral Interface)

SPI Universal Serial Communication Interface SPI Mode

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

Serial Communication. Simplex Half-Duplex Duplex

Understanding SPI with Precision Data Converters

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

Introducing SPI Xpress SPI protocol Master / Analyser on USB

Real Time Embedded Systems. Lecture 1 January 17, 2012

Serial Peripheral Interface (SPI)

Microcontrollers and Interfacing

Amarjeet Singh. January 30, 2012

Serial Peripheral Interface Bus SPI

ZigBee Compliant Platform 2.4G RF Low Power Transceiver Module for IEEE Standard. DATA SHEET Version B

or between microcontrollers)

Motherboard to MicroZed Interfaces

Interfacing the HI7190 to a Microcontroller

UART TO SPI SPECIFICATION

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

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

Module 2.F. Buffered, Interrupt-Driven Printer Design Example. Tim Rogers 2017

LAB4. Program the on chip SPI module

Using FlexIO to emulate communications and timing peripherals

RL78 Serial interfaces

The Serial Peripheral Interface

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

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

Mbed Microcontroller SPI. Spring, 2018 Prof. Jungkeun Park

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

EE 3170 Microcontroller Applications

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

FPGA Implementation Of SPI To I2C Bridge

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

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

Emulating Dual SPI Using FlexIO

HI 3593 ARINC V Dual Receiver, Single Transmitter with SPI Application Note AN 161 June 13, 2012

Marten van Dijk, Syed Kamran Haider

Arduino Uno R3 INTRODUCTION

PIC32 Family Reference Manual

EMX Module Specifications

Transcription:

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

Learning Outcome #3 An ability to effectively utilize the wide variety of peripherals integrated into a contemporary microcontroller How? A: Clocks and Real Time Interrupt (RTI) B: Analog-to-Digital Converter (ATD) C: Serial Peripheral Interface (SPI) D: Timer Module (TIM) E: Pulse Width Modulation (PWM) F: Serial Communications Interface (SCI) [3.B]-2

Learning Outcome #3 One options: Send data in parallel Serial Peripheral Interface (SPI) Why? Want to communicate with a peripheral Better option: Send multi-bit data serially Port X.7. Port Y.2 IRQ Printer STROBE BUSY.. Port Y.3 Port X.0 1 Port Y.1 CLR D Q Q where Port X and Port Y are any available port pins CLK Data [3.B]-3

Basic Description Communication takes place serially Synchronous because a clock signal is involved Operates in Master/Slave Mode. Needs to be one master can be multiple slaves Master defines the clock Operates via shifting in bits each clock cycle Standardized and used for a variety of peripherals: LCDs, D/A converters, etc Can also use it to communicate between microcontrollers [3.B]-4

Basic SPI Operation Master owns the clock MASTER SLAVE MOSI Master Out, Slave In MISO Master In, Slave Out [3.B]-5

9S12 SPI Module Full-Duplex Can manipulate SPI clock Can be program or interrupt-driven. https://engineering.purdue.edu/ece362/refs/9s12c_refs/s12spiv3.pdf [3.B]-6

SPI Block Diagram PM.4 PM.2 PM.5 Port M 24 MHz PM.3 7

SPI Registers SPICR1 (SPI control register 1) SPIE (bit 7) 0 SPI interrupts disabled 1 SPI interrupts enabled SPE (bit 6) 0 SPI system disabled 1 SPI system enabled SPTIE (bit 5) 0 SPTEF (transmit empty) interrupt disabled 1 SPTEF (transmit empty) interrupt enabled indicates default mode after RESET 8

SPI Registers SPICR1 (SPI control register 1) MSTR (bit 4) 0 slave mode enabled 1 master mode enabled CPOL (bit 3) 0 active high clock (SCK low in idle state) 1 active low clock (SCK high in idle state) CPHA (bit 2) 0 data sampling occurs at odd edges of SCK 1 data sampling occurs at even edges of SCK indicates default mode after RESET 9

SPI Clock Format with CPOL=0, CPHA=0 10

SPI Registers SPICR1 (SPI control register 1) SSOE (bit 1) 0 slave select output disabled 1 slave select output enabled (in master mode, provided MODFEN bit is also 1 ) LSBFE (bit 0) 0 data transferred most significant bit first 1 data transferred least significant bit first indicates default mode after RESET 11

SPI Registers SPICR2 (SPI control register 2) BIDIROE (bit 3) MOSI/MISO output enable in bi-directional mode 0 output buffer disabled 1 output buffer enabled SPC0 (bit 0) serial pin control bit 0 bi-directional mode is disabled 1 bi-directional mode enabled indicates default mode after RESET 12

SPI Modes Master Key: Master Slave Input Output 13

SPI Registers SPIBR (baud rate) SPRx (bits 2-0) baud rate preselection bits SPPRx (bits 6-4) baud rate selection bits BaudRateDivisor = (SPPR + 1) 2 (SPR + 1) BaudRate = BusClock / BaudRateDivisor Example: If SPR=000 and SPPR=000 (default), then BaudRateDivisor = 2 BaudRate = BusClock/2 14

SPI Registers SPISR (status) SPIF (bit 7) set after a received data byte is copied into the SPI data register 0 transfer not yet complete 1 received data copied to SPIDR Cleared by reading SPISR (status) register followed by reading SPIDR (data) register SPTEF (bit 5) set when the transmit data register is empty 0 SPI transmit data register not empty 1 SPI transmit data register is empty indicates default mode after RESET 15

SPI Registers SPIDR (data register) serves as both the input and the output data register for the SPI PORTM (Port M data register) MISO (bit 2) SS (bit 3) MOSI (bit 4) SCK (bit 5) 16

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 a clock signal E. none of the above 17

2. The minimum SPI baud rate divisor possible is: A. 1 B. 2 C. 4 D. 8 E. none of the above 18

3. Based on a 24 MHz system clock, the maximum SPI data transfer rate possible (in bits/second) is: A. 2,000,000 bps B. 4,000,000 bps C. 8,000,000 bps D. 12,000,000 bps E. none of the above 19

4. The maximum SPI baud rate divisor possible is: A. 128 B. 896 C. 2048 D. 4608 E. none of the above 20

5. Based on a 24 MHz system clock, the minimum SPI data transfer rate possible (in bits/second) is approximately: A. 8,000 bps B. 11,719 bps C. 93,750 bps D. 1,500,000 bps E. none of the above 21

SPI Initialization Code ; Select 1.5 Mbps baud rate (24 MHz bus) spini movb #$12,spibr [3.B]-22

SPI Registers SPIBR (baud rate) SPRx (bits 2-0) baud rate preselection bits = 010 SPPRx (bits(6-4) baud rate selection bits = 001 BaudRateDivisior = (1 + 1) 2 (2 + 1) = 16 BaudRate = 24 MHz / 16 = 1.5 Mbps SPIBR = x 001 x 010 = $12 23

SPI Initialization Code ; Select 1.5 Mbps baud rate (24 MHz bus) spini movb #$12,spibr ; Master mode, Interrupts off, CPOL=0, ; CPHA=0, slave select disabled, data ; transferred most significant bit first movb #$50,spicr1 [3.B]-24

SPI Registers SPICR1 (SPI control register 1) SPIE (bit 7) 0 SPI interrupts disabled 1 SPI interrupts enabled SPE (bit 6) 0 SPI system disabled 1 SPI system enabled SPTIE (bit 5) 0 SPTEF interrupt disabled 1 SPTEF interrupt enabled indicates default mode after RESET 25

SPI Registers SPICR1 (SPI control register 1) MSTR (bit 4) 0 slave mode enabled 1 master mode enabled CPOL (bit 3) 0 active high clock (SCK low in idle state) 1 active low clock (SCK high in idle state) CPHA (bit 2) 0 data sampling occurs at odd edges of SCK 1 data sampling occurs at even edges of SCK indicates default mode after RESET 26

SPI Registers SPICR1 (SPI control register 1) SSOE (bit 1) 0 slave select output disabled 1 slave select output enabled (in master mode, provided MODFEN bit is also 1 ) LSBFE (bit 0) 0 data transferred most significant bit first 1 data transferred least significant bit first indicates default mode after RESET 27

SPI Initialization Code ; Select 1.5 Mbps baud rate (24 MHz bus) spini movb #$12,spibr ; Master mode, Interrupts off, CPOL=0, ; CPHA=0, slave select disabled, data ; transferred most significant bit first movb #$50,spicr1 ; Normal (non-bidirectional) mode clr spicr2 rts [3.B]-28

SPI Registers SPICR2 (SPI control register 2) BIDIROE (bit 3) MOSI/MISO output enable in bi-directional mode 0 output buffer disabled 1 output buffer enabled SPC0 (bit 0) serial pin control bit 0 bi-directional mode is disabled 1 bi-directional mode enabled indicates default mode after RESET 29

SPI transmit/receive code ;Transmit data passed in A register ;Return data read in B register ;Transmit - wait for SPTEF to set spio brclr spisr,$20,spio staa spidr ;transmit data ;Receive - wait for SPIF to set sprlp brclr spisr,$80,sprlp ldab spidr ;read data rts [3.B]-30

SPI Registers SPISR (status) SPIF (bit 7) set after a received data byte is copied into the SPI data register 0 transfer not yet complete 1 received data copied to SPIDR Cleared by reading SPISR (status) register followed by reading SPIDR (data) register SPTEF (bit 5) set when the transmit data register is empty 0 SPI transmit data register not empty 1 SPI transmit data register is empty indicates default mode after RESET 31

SPI Application Multiple I/O Devices 32

SPI Application 8-bit Shift Register/ Constant Current LED Driver MOSI SCLK MISO (optional) GPIO GPIO 33

SPI Application External 12-bit ATD 34

SPI Application External 8/10/12-bit DTA 35