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

Similar documents
Serial Peripheral Interface (SPI)

Two Wire Interface (TWI) also commonly called I2C

Universal Asynchronous Receiver / Transmitter (UART)

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

spi 1 Fri Oct 13 13:04:

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

< W3150A+ / W5100 Application Note for SPI >

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

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

Understanding SPI with Precision Data Converters

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

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

Using the Z8051 MCU s USI Peripheral as an SPI Interface

ECE2049: Embedded Computing in Engineering Design C Term Spring 2018

Timer 32. Last updated 8/7/18

Serial Peripheral Interface (SPI)

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

Serial Peripheral Interface (SPI) Host Controller Data Sheet

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

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

Microcontrollers and Interfacing

Menu. What is SPI? EEL 3744 EEL 3744 SPI

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

Design with Microprocessors

SPI 3-Wire Master (VHDL)

SPI Block User Guide V02.07

ADC 14. Last updated 9/1/18

ECE 471 Embedded Systems Lecture 20

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

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

CapSense I 2 C/SPI Timer Flash RAM

Real-Time Embedded Systems. CpE-450 Spring 06

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

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

SPI: Serial Peripheral Interface

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

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

063[[[0LFURFRQWUROOHUV 63,

Groking the Linux SPI Subsystem FOSDEM Matt Porter

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

ECE2049: Embedded Computing in Engineering Design C Term Spring 2018 Lecture #20: Using SPI The DAC

Using FlexIO to emulate communications and timing peripherals

PARALLEL COMMUNICATIONS

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

Introduction to I2C & SPI. Chapter 22

EE 308 Spring Using the 9S12 SPI

For reference only Refer to the latest documents for details

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

Embedded Systems - FS 2018

AT03255: SAM D/R/L/C Serial Peripheral Interface (SERCOM SPI) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

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

CPE 323: MSP430 Serial Communication

Marten van Dijk, Syed Kamran Haider

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

Lecture 25 March 23, 2012 Introduction to Serial Communications

Emulating Dual SPI Using FlexIO

LAB4. Program the on chip SPI module

Lecture 14 Serial Peripheral Interface

C8051F700 Serial Peripheral Interface (SPI) Overview

DCB1M - Transceiver for Powerline Communication

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

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

Embedded Systems - FS 2018

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.

Serial Peripheral Interface Bus SPI

Serial Communication. Spring, 2018 Prof. Jungkeun Park

ArduCAM-M-2MP Camera Shield

Raspberry Pi - I/O Interfaces

Interrupts. Why Interrupts

Order Number: MC68HC55 Rev. 2 MC68HC55/D Technical Data Two-Channel CMOS ASIC Device Section 1. DSI/D (Distributed System Interface Digital) 1.1 Featu

If we can just send 1 signal correctly over the SPI MOSI line, then Lab 4 will work!!!

ICS Humla CTF. Copyright 2017 Payatu 1

Interfacing Techniques in Embedded Systems

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

Section 16. Basic Sychronous Serial Port (BSSP)

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

ECE 4510/5530 Microcontroller Applications Week 6

Design Development and Implementation of SPI

Serial communications with SPI

Serial Communication. Simplex Half-Duplex Duplex

INTRODUCTION TO FLEXIO

Serial Peripheral Interface (SPI)

Interfacing CMR3000-D01 to an MSP430 ultra low-power microcontroller

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

Network Embedded Systems Sensor Networks Fall Hardware. Marcus Chang,

PIC16C7X 11.0 SYNCHRONOUS SERIAL PORT (SSP) MODULE SSP Module Overview. Applicable Devices

OEM API Specification

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

ECE Microcontrollers. Serial Peripheral Interface (SPI) & NRF24 Radio

C-CODE EXAMPLE FOR SCP1000-D01 PRESSURE SENSOR

Serial versus Parallel Data Transfers

BroadR-Reach click PID: MIKROE Weight: 26 g

Amarjeet Singh. January 30, 2012

Real Time Embedded Systems. Lecture 1 January 17, 2012

output current sink/source 2 ma PIC 16F690 (see datasheet) SPI resolution 12 bit position accuracy 0.2 deg

Pedometer 3 Click. PID: MIKROE 3259 Weight: 24 g

Serial Communications

DISCONTINUED. SPI Communication with AMT bit Absolute Encoder

YOU WILL NOT BE ALLOWED INTO YOUR LAB SECTION WITHOUT THE REQUIRED PRE-LAB.

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

Transcription:

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

MSP432 SPI eusci = enhanced Universal Serial Communications Interface 2 tj

MSP432 SPI ARM (AMBA Compliant) 7/8 bit transmission Master/Slave LSB/MSB first Separate RX/TX registers 4 A modules and 4 B modules 3 tj

Overview 8 bit synchronous shift register used to communicate externally Most often used to communicate with peripherals displays, sensors, converters Can be used for inter-processor communication Two modes of operation Master responsible for providing the clock Slave receives clock from the master 4 tj

Overview Master Slave LATCH LATCH MISO MISO SHIFT REGISTER MOSI SHIFT REGISTER MOSI SCK SCK SPI CLOCK GENERATOR SS SPI CLOCK GENERATOR SS MISO Master:IN or Slave:OUT MOSI Master:OUT or Slave:IN SCK SPI CLK SS Slave Select Bar 5 tj

Operation Master Slave LATCH LATCH MISO MISO SHIFT REGISTER MOSI MOSI SHIFT REGISTER SCK SCK SPI CLOCK GENERATOR SS X 0 SS SPI CLOCK GENERATOR Latch Shift Register in both master and slave Master generates 8 clocks shifts both registers (swaps content) Shift Register Latch in both master and slave 6 tj

Operation Configure 1 device as master Configure 1 or more devices as slaves Load values into register(s) Pull SSbar low on the desired slave device Initiate transfer by writing to the data register The master will generate the appropriate clocks If interrupts are enabled an interrupt will be generated on completion 7 tj

Msb Lsb SPI Operation 2 options for clock polarity CPOL = 0 rising edge triggered CPOL = 1 falling edge triggered 2 options for clock phase CPHA = 0 leading edge triggered CPHA = 1 trailing edge triggered MISO DORD=1 DORD=0 2 options on transfer direction DORD = 0 MSB transferred first DORD = 1 LSB transferred first DORD=0 DORD = 1 DORD = 0 SHIFT REGISTER DORD=1 MOSI 8 tj

Operation CPHA = 0 Captured in register on leading clock edge Values active on pins as soon as SSbar goes low New values placed on pins on trailing clock edge 9 tj

Operation CPHA = 1 Captured in register on trailing clock edge Values active on pins on first clock edge New values placed on pins on leading clock edge 10 tj

Operation Multiple Slave Configuration 11 tj

Operation Multiple Slave Extended Shift Configuration 12 tj

Implementation Separate RX/TX registers Separate RX/TX buffers State Machine Clock divider Control register Status register 13 tj

Master Mode Receive/Transmit initiated by writing to TX buffer Data is moved to the TX shift register as soon as it is empty UCTXIFG flag set transfer is NOT complete Transfer is controlled by the state machine When complete RX data moved to the RX buffer UCRXIFG flag is set transfer is complete 14 tj

Slave Mode External clock controls the transfer Data is moved to the TX shift register as soon as it is empty UCTXIFG flag set transfer is NOT complete When complete, RX data moved to the RX buffer UCRXIFG flag is set UCOE flag is set if the RX buffer has not been read prior to a new completed transfer 15 tj

MSP432 SPI Registers 16 tj

MSP432 SPI Control Register 0 EUCSI_nx_SPI->CTLW0 n = A or B x = 0, 1, 2, 3 17 tj

MSP432 SPI Control Register 0 18 tj

MSP432 SPI Bit Rate Control Register SPI transfer bit rate: f BitClock = f BRCLK /UCBRx EUCSI_nx_SPI->BRW n = A or B x = 0, 1, 2, 3 BRCLK: ACLK or SMCLK 19 tj

MSP432 SPI Status Register EUCSI_nx_SPI->STATW n = A or B x = 0, 1, 2, 3 20 tj

MSP432 SPI Receive Buffer EUCSI_nx_SPI->RXBUF n = A or B x = 0, 1, 2, 3 21 tj

MSP432 SPI Transmit Buffer EUCSI_nx_SPI->TXBUF n = A or B x = 0, 1, 2, 3 22 tj

MSP432 SPI Interrupt Enable Register EUCSI_nx_SPI->IE n = A or B x = 0, 1, 2, 3 23 tj

MSP432 SPI Interrupt Flag Register EUCSI_nx_SPI->IFG n = A or B x = 0, 1, 2, 3 24 tj

MSP432 SPI Interrupt Vector Register EUCSI_nx_SPI->IV n = A or B x = 0, 1, 2, 3 25 tj

MSP432 SPI Registers Module B similar to module A 26 tj

MSP432 SPI Config 27 tj

MSP432 SPI Config 28 tj

MSP432 SPI Loopback example Note EUSCI_B3 pins are wired up to the onboard RGB LEDs /* * spi_example.c * * Created on: Aug 7, 2018 * Author: johnsontimoj */ ////////////////////////////////// // // use 2 spi interfaces to loopback // // input none // // output - printf of spi register values // // Transfer a count value back and forth // /////////////////////////////////// // includes #include <stdio.h> #include "msp432.h" #include "msoe_lib_all.h" void pin_setup(void); void spi_master_setup(void); void spi_slave_setup(void); 29 tj

MSP432 SPI Loopback example int main(void){ // // setup counter uint8_t count = 0; // Configure pins pin_setup(); // Setup SPIs spi_master_setup(); spi_slave_setup(); while(1){ // Load slave with a value to return EUSCI_B3_SPI->TXBUF = 0xFF - count; // Write to master buffer to initiate transfer EUSCI_A1_SPI->TXBUF = count; // wait for transfer to complete Delay_3MHz_ms(10); // Print rcvd values printf("master sent %i - Slave sent %i\n", EUSCI_B3_SPI->RXBUF, EUSCI_A1_SPI->RXBUF); // Update count and wait count ++; Delay_3MHz_ms(1000); } return 0; } // end main 30 tj

MSP432 SPI Loopback example void pin_setup(void){ // Setup USCIA1 as master // Setup USCIB0 as slave // Transfer data from Master to slave in a while loop // // USCIA1 --> P2.0-STE, P2.1- CLK, P2.2-SOMI, P2.3-SIMO // USCIB3 --> P10.0-STE, P10.1-CLK, P10.3-SOMI, P10.2-SIMO // P2->SEL0 = 0x0F; // Set to USC mode P2->SEL1 &= ~0x0F; // 0-1 mode P10->SEL0 = 0x0F; P10->SEL1 &= ~0x0F; // Nothing else needed - the module sets directions return; } // end pin_setup 31 tj

MSP432 SPI Loopback example void spi_master_setup(void){ // USCIA1 - master // CPOL-0, CPHA-0, 8 bit, LSB first // // CTLW0 // PH POL LSB 8b master 4/ssb sync Aclk ss rst // 0 0 0 0 1 10 1 01 xxxx 1 1 // 0D42 EUSCI_A1_SPI->CTLW0 = 0x0D43; // // BRW // 0000 0000 0100 0000 // 0040 EUSCI_A1_SPI->BRW = 0x0040; // // No interrupts for now // // Release reset EUSCI_A1_SPI->CTLW0 &= ~0x0001; return; } // end spi_master_setup void spi_slave_setup(void){ // USCIB3 - master // CPOL-0, CPHA-0, 8 bit, LSB first // // CTLW0 // PH POL LSB 8b slave 4/ssb sync Aclk ss no rst // 0 0 0 0 0 10 1 01 xxxx 1 0 // 0542 EUSCI_B3_SPI->CTLW0 = 0x0542; // // No interrupts for now return; } // end spi_slave_setup 32 tj