Design and Implementation of Serial Peripheral Interface Protocol Using Verilog HDL

Similar documents
Implementing SPI Communication Between MSP430 G2452 and LTC ADC

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

Implementing SPI Master and Slave Functionality Using the Z8 Encore! F083A

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

Design and Verification of Nine port Network Router

Using the HT46R46 I/O Ports to Implement Half-Duplex SPI Communication

AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

SPI I2C LIN Ethernet. u Today: Wired embedded networks. u Next lecture: CAN bus u Then: wireless embedded network

Elettronica dei Sistemi Digitali Costantino Giaconia SERIAL I/O COMMON PROTOCOLS

Design and Functional Verification of A SPI Master Slave Core Using System Verilog

SafeSPI - Serial Peripheral Interface for Automotive Safety

A DIY Hardware Packet Sniffer

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

MicroMag3 3-Axis Magnetic Sensor Module

Serial Communications

Data Sheet. Adaptive Design ltd. Arduino Dual L6470 Stepper Motor Shield V th November L6470 Stepper Motor Shield

Embedded Systems Design Course Applying the mbed microcontroller

Serial Communications

Part 1. MAX BIT DAC with an Arduino Board. MIDI to Voltage Converter Part1

Embedded Ethernet Interface Using Arm Processor

USER GUIDE EDBG. Description

Using Altera MAX Series as Microcontroller I/O Expanders

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

Raspberry Pi. Hans- Petter Halvorsen, M.Sc.

SPI. Overview and Use of the PICmicro Serial Peripheral Interface. Getting Started: SPI

SDLC Controller. Documentation. Design File Formats. Verification

AND8336. Design Examples of On Board Dual Supply Voltage Logic Translators. Prepared by: Jim Lepkowski ON Semiconductor.

M25P05-A. 512-Kbit, serial flash memory, 50 MHz SPI bus interface. Features

Modeling Registers and Counters

Design and Implementation of an On-Chip timing based Permutation Network for Multiprocessor system on Chip

9/14/ :38

Pmod peripheral modules are powered by the host via the interface s power and ground pins.

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: EC Microprocessor & Microcontroller Year/Sem : II/IV

The Programming Interface

The I2C Bus. NXP Semiconductors: UM10204 I2C-bus specification and user manual HAW - Arduino 1

Implementing MOD bus and CAN bus Protocol Conversion Interface

8051 MICROCONTROLLER COURSE

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

Hello, and welcome to this presentation of the STM32 SDMMC controller module. It covers the main features of the controller which is used to connect

TERMINAL Debug Console Instrument

AN141 SMBUS COMMUNICATION FOR SMALL FORM FACTOR DEVICE FAMILIES. 1. Introduction. 2. Overview of the SMBus Specification. 2.1.

Using Xbee in Serial Communication

Serial Communications (Chapter 10) RS232, SPI, I2C

DECT Module UM-9802 Datasheet

FPGA INTEGRATION MANUAL SATURN-SIL 2 MODULES. Dictionary Code. Edition 01. Revision 00. Number of pages 18

Allows the user to protect against inadvertent write operations. Device select and address bytes are Acknowledged Data Bytes are not Acknowledged

Objectives. Basics of Serial Communication. Simplex vs Duplex. CMPE328 Microprocessors (Spring ) Serial Interfacing. By Dr.

Lab 1: Introduction to Xilinx ISE Tutorial

Integration of Arduino as a slave system to LonWorks based System using I2C Interface

Atmel Norway XMEGA Introduction

Post-Configuration Access to SPI Flash Memory with Virtex-5 FPGAs Author: Daniel Cherry

Figure 1 FPGA Growth and Usage Trends

EXPERIMENT 8. Flip-Flops and Sequential Circuits

Digitale Signalverarbeitung mit FPGA (DSF) Soft Core Prozessor NIOS II Stand Mai Jens Onno Krah

Decimal Number (base 10) Binary Number (base 2)

Bluetooth to serial HC-06 wireless module

Below is a diagram explaining the data packet and the timing related to the mouse clock while receiving a byte from the PS-2 mouse:

FR FAMILY MB91460 SPI - DAISY CHAIN COMMUNICATION 32-BIT MICROCONTROLLER APPLICATION NOTE. Fujitsu Microelectronics Europe Application Note

Microcontroller Based Low Cost Portable PC Mouse and Keyboard Tester

NB3H5150 I2C Programming Guide. I2C/SMBus Custom Configuration Application Note

Digital Systems Design! Lecture 1 - Introduction!!

Von der Hardware zur Software in FPGAs mit Embedded Prozessoren. Alexander Hahn Senior Field Application Engineer Lattice Semiconductor

CONSTRAINT RANDOM VERIFICATION OF NETWORK ROUTER FOR SYSTEM ON CHIP APPLICATION

Microtronics technologies Mobile:

CAN bus board. EB018

RAPID PROTOTYPING OF DIGITAL SYSTEMS Second Edition

How To Design A Single Chip System Bus (Amba) For A Single Threaded Microprocessor (Mma) (I386) (Mmb) (Microprocessor) (Ai) (Bower) (Dmi) (Dual

The 104 Duke_ACC Machine

AT15007: Differences between ATmega328/P and ATmega328PB. Introduction. Features. Atmel AVR 8-bit Microcontrollers APPLICATION NOTE

Chapter 13. PIC Family Microcontroller

Serial port interface for microcontroller embedded into integrated power meter

I 2 C Master Mode Overview and Use of the PICmicro MSSP I 2 C Interface with a 24xx01x EEPROM

LIN (Local Interconnect Network):

International Journal of Advancements in Research & Technology, Volume 2, Issue3, March ISSN

A New Paradigm for Synchronous State Machine Design in Verilog

- 35mA Standby, mA Speaking pre-defined phrases with up to 1925 total characters.

RS-485 Protocol Manual

a8251 Features General Description Programmable Communications Interface

MARTECH SPI Tools. MARTECH SPI Tools User Manual v1.0. User Manual

In-Vehicle Networking

JTAG-HS2 Programming Cable for Xilinx FPGAs. Overview. Revised January 22, 2015 This manual applies to the HTAG-HS2 rev. A

GTS-4E Hardware User Manual. Version: V1.1.0 Date:

Introduction: Implementation of the MVI56-MCM module for modbus communications:

CHAPTER 11: Flip Flops

A Verilog HDL Test Bench Primer Application Note

Internal Oscillator. I 2 C Interface. SPI Interface. Controller. Internal Registers Port Controller. Eight I/O Pins. Figure 1.

The Boundary Scan Test (BST) technology

Switch Fabric Implementation Using Shared Memory

Best Practises for LabVIEW FPGA Design Flow. uk.ni.com ireland.ni.com

8051 Serial Port. Crystal TXD. I/O Device RXD. Embedded Systems Peripherals

TURBO PROGRAMMER USB, MMC, SIM DEVELOPMENT KIT

Microprocessor & Assembly Language

Software User Guide UG-461

In-System Programmer USER MANUAL RN-ISP-UM RN-WIFLYCR-UM

CENTRONICS interface and Parallel Printer Port LPT

SPI Flash Programming and Hardware Interfacing Using ispvm System

Design and Implementation of Vending Machine using Verilog HDL

Measurement and Analysis Introduction of ISO7816 (Smart Card)

Chapter 02: Computer Organization. Lesson 04: Functional units and components in a computer organization Part 3 Bus Structures

Dolphin In-Circuit programming Updating Firmware in the field

Transcription:

Design and Implementation of Serial Peripheral Interface Protocol Using Verilog HDL Fareha Naqvi 1 1 Student Department of Electronics and Communication Engineering, Alfalah School of Engineering & Technology, Maharishi Dayanand University, Rohtak, Haryana, India Abstract - The objective of this paper is the design and implementation of SPI (serial peripheral interface) master and slave using verilog HDL. The SPI (serial peripheral interface) is a type of serial communication protocol that transfers synchronous serial data in full duplex mode. There are two modes of communications in SPI viz., master and slave. While the master device generates serial clock, the slave devices are allowed with individual slave select lines and the whole design is simulated and synthesized with Xilinx ISE design suite 13.3.1 Keywords - SPI (serial peripheral interface), Verilog HDL. I. INTRODUCTION Serial to Peripheral Interface (SPI) is a hardware/firmware communications protocol developed by Motorola and later adopted by others in the industry. Sometimes SPI is also called a "four wire" serial bus.the Serial Peripheral Interface or SPI-bus is a simple 4-wire serial communications interface used by many microprocessor/microcontroller peripheral chips that enables the controllers and peripheral devices to communicate with each other. Even though it is developed primarily for the communication between host processor and peripherals, a connection of two processors via SPI is just as well possible. The SPI bus, which operates at full, is a synchronous type data link setup with a Master / Slave interface. Both single-master and multi-master protocols are possible in SPI. The SPI Bus is usually used only on the PCB. The SPI Bus was designed to transfer data between various IC chips, at very high speeds II. SERIAL PERIPHERAL INTERFACE DESIGN The internal architecture of SPI mainly consists of two modules, master module and slave module as shown in figure 1. The SPI module allows a full duplex, synchronous, serial communication between the MCU and peripheral devices [1]. The main parts of the SPI are status, control and data registers, shifter logic, baud rate generator, master/slave control logic and port control logic. Software can poll the SPI status flags or the SPI operation can be interrupt driven. The SPI module has a total of 4 external pins: Master out Slave in (MOSI) - Output data from the master to the inputs of the slaves. Master in Slave out (MISO) - Output data from a slave to the input of the master. Serial Clock (SCLK) - Clock driven by the master to slaves, used to synchronize the data bits. Slave Select (SS) - Select signal driven by the master to individual slaves, used to select the target slave [2]. Figure 1: SPI Block Diagram The main element of the SPI system is the SPI Control Register and the SPI Data Register. The control word written into the Control Register determines the mode in which the SPI shall be configured. The 8-bit data register in the master and the 8-bit data register in the slave are linked by the MOSI and MISO pins to form a distributed 16-bit register. When a data transfer operation is performed, this 16-bit register is serially shifted eight bit positions by the serial clock from the master. Consequently, data is exchanged between the master and the slave. Data written to the master SPI Data Register becomes the output data for the slave, and data read from the master SPI Data Register after a transfer operation is the input data from the slave. The SPI system operates in two modes master and slave. IJEDR1503092 International Journal of Engineering Development and Research (www.ijedr.org) 1

III. MASTER MODE OPERATION The SPI operates in master mode when the MSTR control bit is set. The transmission begins by writing to the master SPI Transmit Data Register. If the shift register is empty, the byte immediately transfers to the shift register. Once the byte is transferred from the SPI transmit register to the shift register, the SPTE control bit is set indicating that another byte can be written to the SPI transmit data register. In master mode, before transmission SS pin is connected to VDD if the single slave module is used. Then the byte begins shifting out a bit at a time on the MOSI pin synchronized with the master serial clock. The data transmission will continue for 8 clock cycles, transferring all 8-bits. The transmission ends when the whole byte is shifted out of the master SPI shift register into the slave SPI shift register. The slave shift register is then automatically transferred to the slave SPI receive data register if it is empty. The SPRF control bit is set indicating that the SPI receive register is full and waiting to be read [3]. IV. SLAVE MODE OPERATION The SPI operates in slave mode when the MSTR bit in SPI.In slave mode, SCK is the SPI clock input from the master, the function of the serial data output pin (MISO) and serial data input pin (MOSI) is determined by the SPC0 bit and BIDIROE bit in SPI Control Register 2. And the SS pin is the slave select input. Before a data transmission the SS pin is connected to ground if the single slave module is used. Once the byte is transferred from the SPI transmit register to the shift register, the SPTE control bit is set indicating that another byte can be written to the SPI transmit data register. The byte of data shifting a bit at time on the MISO pin synchronized with the master serial clock. The master shift register is then automatically transferred to the master SPI receive data register if it is empty. The SPRF control bit is set indicating that the SPI receive register is full and waiting to be read. V. SPI DATA TRANSMISSION SPI interface allows to transmit and receive data simultaneously on two lines (MOSI and MISO). Clock polarity (CPOL) and clock phase (CPHA) are the main parameters that define a clock format to be used by the SPI bus. Depending on CPOL parameter, SPI clock may be inverted or non-inverted. When clock polarity is set to 1, the idle state for SCLK is high [4].CPHA parameter is used to shift the sampling phase. If CPHA=0 the data are sampled on the leading (first) clock edge. If CPHA=1 the data are sampled on the trailing (second) clock edge, regardless of whether that clock edge is rising or falling. Clock polarity = 0, Clock phase = 0 Figure 2: Clock polarity = 0, Clock phase = 0 The data must be available before the first clock signal rising. The clock idle state is zero. The data on MISO and MOSI lines must be stable while the clock is high and can be changed when the clock is low. The data is captured on the clock's low-to-high transition and propagated on high-to-low clock transition. Clock polarity = 0, Clock phase = 1 Figure 3: Clock polarity = 0, Clock phase = 1 The first clock signal rising can be used to prepare the data. The clock idle state is zero. The data on MISO and MOSI lines must be stable while the clock is low and can be changed when the clock is high. The data is captured on the clock's high-to-low transition and propagated on low-to-high clock transition. Clock polarity = 1, Clock phase = 0 IJEDR1503092 International Journal of Engineering Development and Research (www.ijedr.org) 2

Figure 4: Clock polarity = 1, Clock phase = 0 The data must be available before the first clock signal falling. The clock idle state is one. The data on MISO and MOSI lines must be stable while the clock is low and can be changed when the clock is high. The data is captured on the clock's high-to-low transition and propagated on low-to-high clock transition. Clock polarity = 1, Clock phase = 1 Figure 5: Clock polarity = 1, Clock phase = 1 The first clock signal falling can be used to prepare the data. The clock idle state is one. The data on MISO and MOSI lines must be stable while the clock is high and can be changed when the clock is low. The data is captured on the clock's low-to-high transition and propagated on high-to-low clock transition. VI. SIMULATION AND RESULTS The data transmission from master to slave and slave to master has been synthesized using the Xilinx ISE design suite 13.3.1 and the simulation results are shown in figure respectively. IJEDR1503092 International Journal of Engineering Development and Research (www.ijedr.org) 3

Figure 6: SPI RTL Schematic of Top Module Figure 7: SPI Master to Slave Data Transmission IJEDR1503092 International Journal of Engineering Development and Research (www.ijedr.org) 4

Figure7: SPI Slave to Master Data Transmission VII. CONCLUSION The SPI Master and Slave has been implemented using verilog HDL and Xilinx ISE 13.3.1 was used for simulation. The basis of this paper is the focus on data transmission between master and slave modules. We have verified the data in slave device same as the data in the master device and various possible cases of clock polarity and clock phase are verified. Further, we have also done functional verification. REFERENCES [1] Motorola Inc., SPI Block Guide V03.06, February 2003 [2] Quartus II Handbook version 9.0 volume 5: Embedded Peripherals. Altera SPI core interval time core chapter in volume 5 of the Quartus II. [3] Digital DNA from Motorola, SPI Tutorial introduction. [4] F.Leens, An Introduction to I2C and SPI Protocols, IEEE Instrumentation & Measurement Magazine, pp. 8-13, February 2009. [5] A.K. Oudjida et al, FPGA Implementation of I2C and SPI Protocols: A Comparative Study. Proceedings of the 16th edition of the IEEE International Conference on Electronics Circuits and Systems ICECS, pp. 507-510, ISBN: 978-1-4244-5091- 6,December 13-16 2009, Yasmine Hammamet, Tunisia. [6] Bhaskar. J, A Verilog HDL Primer, Publisher: Syndicate Publications. IJEDR1503092 International Journal of Engineering Development and Research (www.ijedr.org) 5