Serial Interconnect Buses I 2 C (SMB) and SPI



Similar documents
Chapter 13. PIC Family Microcontroller

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

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

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

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

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

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

I2C PRESSURE MONITORING THROUGH USB PROTOCOL.

Definitions and Documents

MX PIC24F Educational Module User Manual

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

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

Microtronics technologies Mobile:

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

AN736. An I 2 C TM Network Protocol for Environmental Monitoring THE I 2 C BUS SPECIFICATION INTRODUCTION

Chapter 1 Lesson 3 Hardware Elements in the Embedded Systems Chapter-1L03: "Embedded Systems - ", Raj Kamal, Publs.: McGraw-Hill Education

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

Embedded Systems Design Course Applying the mbed microcontroller

Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol

SafeSPI - Serial Peripheral Interface for Automotive Safety

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

AN1229. Class B Safety Software Library for PIC MCUs and dspic DSCs OVERVIEW OF THE IEC STANDARD INTRODUCTION

Microcontroller Based Low Cost Portable PC Mouse and Keyboard Tester

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

Serial Communications

2.0 Command and Data Handling Subsystem

Microcontrollers in Practice

Web Site: Forums: forums.parallax.com Sales: Technical:

Implementing MOD bus and CAN bus Protocol Conversion Interface

AVR315: Using the TWI Module as I2C Master. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

Design and Verification of Nine port Network Router

USING I2C WITH PICAXE

The I 2 C-bus and how to use it (including specifications)

Atmel Norway XMEGA Introduction

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

LOCAL INTERCONNECT NETWORK (LIN)

Using Altera MAX Series as Microcontroller I/O Expanders

Serial Communications

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

Microprocessor or Microcontroller?

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

MODULE BOUSSOLE ÉLECTRONIQUE CMPS03 Référence :

USER GUIDE EDBG. Description

Fondamenti su strumenti di sviluppo per microcontrollori PIC

A+ Guide to Managing and Maintaining Your PC, 7e. Chapter 1 Introducing Hardware

MicroMag3 3-Axis Magnetic Sensor Module

Bluetooth to serial HC-06 wireless module

Serial port interface for microcontroller embedded into integrated power meter

PICNet 1. PICNet 1 PIC18 Network & SD/MMC Development Board. Features. Applications. Description

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

Fairchild Solutions for 133MHz Buffered Memory Modules

THE I 2 C-BUS SPECIFICATION VERSION 2.1 JANUARY document order number:

VDIP1. Vinculum VNC1L Module. Datasheet

Implementing SPI Communication Between MSP430 G2452 and LTC ADC

CAN bus board. EB018

The Programming Interface

Accurate Measurement of the Mains Electricity Frequency

Chapter 5 Real time clock by John Leung

Display Message on Notice Board using GSM

MPR121 Serial Communication

UM I 2 C-bus specification and user manual. Document information

DS2401 Silicon Serial Number

A DIY Hardware Packet Sniffer

AVR311: Using the TWI Module as I2C Slave. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

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

Palaparthi.Jagadeesh Chand. Associate Professor in ECE Department, Nimra Institute of Science & Technology, Vijayawada, A.P.

Application Note: AN00141 xcore-xa - Application Development

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

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

AUTOMATIC NIGHT LAMP WITH MORNING ALARM USING MICROPROCESSOR

Real-time Operating Systems Lecture 27.1

ES_LPC4357/53/37/33. Errata sheet LPC4357/53/37/33. Document information

USB / Data-Acquisition Module NOW LEAD-FREE

Freescale Semiconductor, Inc. Product Brief Integrated Portable System Processor DragonBall ΤΜ

ARM Cortex -A8 SBC with MIPI CSI Camera and Spartan -6 FPGA SBC1654

Wireless Security Camera

Microcomputer Protocol Implementation at Local Interconnect Network Georgi Krastev

Design of a High Speed Communications Link Using Field Programmable Gate Arrays

AN4646 Application note

Features INSTRUCTION DECODER CONTROL LOGIC AND CLOCK GENERATORS COMPARATOR AND WRITE ENABLE EEPROM ARRAY READ/WRITE AMPS 16

Distributed Real-Time Systems (TI-DRTS) Track 2. CAN-BUS Introduction. Version Ref. VECTOR application note & Motorola note

Lab Experiment 1: The LPC 2148 Education Board

An Introduction to MPLAB Integrated Development Environment

DS1821 Programmable Digital Thermostat and Thermometer

Computer Organization and Components

Tutorial for MPLAB Starter Kit for PIC18F

Objectives. Units of Memory Capacity. CMPE328 Microprocessors (Spring ) Memory and I/O address Decoders. By Dr.

MS BA03 Barometric Pressure Sensor, with stainless steel cap

Computer Systems Structure Input/Output

RS-485 Protocol Manual

Local Interconnect Network Training. Local Interconnect Network Training. Overview

M68EVB908QL4 Development Board for Motorola MC68HC908QL4

C8051F020 Utilization in an Embedded Digital Design Project Course. Daren R. Wilcox Southern Polytechnic State University Marietta, Georgia

DATA LOGGER AND REMOTE MONITORING SYSTEM FOR MULTIPLE PARAMETER MEASUREMENT APPLICATIONS. G.S. Nhivekar, R.R.Mudholker

Software engineering for real-time systems

Random-Access Memory (RAM) The Memory Hierarchy. SRAM vs DRAM Summary. Conventional DRAM Organization. Page 1

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

AN3998 Application note

LIN (Local Interconnect Network):

Transcription:

Purpose of Serial Interconnect Buses Serial Interconnect Buses I 2 C (SMB) and SPI 55:06 Embedded Systems and Systems Software Provide low-cost i.e low wire/pin count connection between IC devices There are lots of serial bus standards I 2 C SMB SPI Microwire Maxim -wire Maxim/allas 1-wire etc. Purpose of Serial Interconnect Buses Provide low-cost i.e low wire/pin count connection between IC devices There are lots of serial bus standards I 2 C SMB We ll focus on these. SPI Microwire Maxim -wire Maxim/allas 1-wire etc. Serial Peripheral Interface (SPI) Originally developed by Motorola Synchronous, serial protocol ata timing is controlled by an explicit clock signal () -slave device controls the clock Bi-directional data exchange data clocked into and out-of device at same time 1

SPI signals SPI ata Loop (CS) ( Select, Chip Select) When is low the slave is enabled (Serial Clock) s the sending and reading of data S0 (Serial ata Out) Carries data OUT of the device (Serial ata In) Carries data INTO the device SPI ata Loop Internal Shift Register: Loaded by SPI data or from SPI ata Loop Serial Buffer: This is the register read and written by your program 2

SPI ata Loop SPI ata Loop generates the clock the controls the data transfer controls which slave is selected by asserting the slave s PIC 18F452 SPI Module PIC 18F452 SPI Module RC5/S0 RC5/S0 PIR1 PIF RC4/ RC/ ctually the SPI Interface is part of a multifunctional PIC module called MP ( Synchronous Serial Port) that supports both SPI and I 2 C PIR1 PIF RC4/ RC/

PIC 18F452 SPI Module PIC 18F452 SPI Module RC5/S0 RC5/S0 RC4/ RC4/ write to initiates both and transfers write to initiates both and transfers PIF RC/ PIF t completion of transfer PIF is set (must be cleared prior to next transfer). now holds input RC/ SPI Timing SPI Modes 4

SPI Modes Connecting Multiple SPI evices Mode selection is controlled by three bits: CKP (Clock Polarity) CKE (Clock edge select) SMP (SPI sample time) etermining the right mode to use for a given device can be tricky (see section 15. in the text) arbitrary pins (RC5)(RC4)(RC) PIC18F452 () SPI 1 SPI K Connecting Multiple SPI evices Connecting Multiple SPI evices arbitrary pins (RC5)(RC4)(RC) PIC18F452 () SPI 1 SPI K arbitrary pins (RC5)(RC4)(RC) PIC18F452 () SPI 1 SPI K selection is NOT handled by the MP Unit Note: On the QwikFlash Boards the MX522 C is permanently connected to the SPI interface (RC0 is used for ) Pins RC-RC5 (,, ) are also brought out to the H2 expansion header to allow connection of additional SPI devices 5

Using SPI with C18 C Setting up the SPI Unit Function: Initialize the P module. Include: spi.h Prototype: void OpenSPI( unsigned char sync_mode, unsigned char bus_mode, unsigned char smp_phase); Using SPI with C18 C Setting up the SPI Unit (continued) rguments: sync_mode One of the following values, defined in spi.h: SPI_FOSC_4 SPI mode, clock = FOSC/4 SPI_FOSC_16 SPI mode, clock = FOSC/16 SPI_FOSC_64 SPI mode, clock = FOSC/64 SPI_FOSC_TMR2 SPI mode, clock = TMR2 output/2 SLV_ON SPI mode, / pin control enabled SLV_OFF SPI mode, / pin control disabled bus_mode One of the following values, defined in spi.h: MOE_00 Setting for SPI bus Mode 0,0 MOE_01 Setting for SPI bus Mode 0,1 MOE_10 Setting for SPI bus Mode 1,0 MOE_11 Setting for SPI bus Mode 1,1 Using SPI with C18 C Setting up the SPI Unit (continued) smp_phase One of the following values, defined in spi.h: SMPEN Input data sample at end of data out SMPMI Input data sample at middle of data out Remarks: This function sets up the P module for use with a SPI bus device. File Name: spi_open.c Code Example: OpenSPI(SPI_FOSC_16, MOE_00, SMPEN); Using SPI with C18 C Writing to the SPI bus: WriteSPI putcspi Function: Write a byte to the SPI bus. Include: spi.h Prototype: unsigned char WriteSPI(unsigned char data_out ); unsigned char putcspi( unsigned char data_out ); rguments: data_out Value to be written to the SPI bus. Remarks: This function writes a single data byte out and then checks for a write collision. putcspi is defined to be WriteSPI in spi.h. Return Value: 0 if no write collision occurred -1 if a write collision occurred File Name: spi_writ.c #define in spi.h Code Example: WriteSPI( a ); 6

Using SPI with C18 C Reading from the SPI bus: ReadSPI getcspi Function: Read a byte from the SPI bus. Include: spi.h Prototype: unsigned char ReadSPI( void ); unsigned char getcspi( void ); Remarks: This function initiates a SPIx bus cycle for the acquisition of a byte of data. getcspi is defined to be ReadSPI in spi.h. Return Value: This function returns a byte of data read during a SPI read cycle. File Name: spi_read.c #define in spi.h Code Example: char x; x = ReadSPI(); nother Serial Bus I 2 C (Inter-IC) Two-wire serial bus protocol developed by Philips Semiconductors nearly 20 years ago Enables peripheral ICs to communicate using simple communication hardware ata transfer rates up to 100 kbits/s and 7-bit addressing possible in normal mode.4 Mbits/s and 10-bit addressing in fast-mode Common devices capable of interfacing to I 2 C bus: EPROMS, Flash, and some RM memory, real-time clocks, watchdog timers, and microcontrollers I2C bus structure I2C bus structure EEPROM (servant) Temp. Sensor (servant) Microcontroller (servant) Sensor controller EEPROM Temp. LC- (master) (servant) (servant) < 400 pf Microcontroller (master) LCcontroller (servant) PIC18f452 uses pins RC/RC4. rivers are opendrain so pullup resisters are needed See section 17. in the text. < 400 pf ddr=0x01 ddr=0x02 ddr=0x0 ddr=0x01 ddr=0x02 ddr=0x0 Start condition Sending 0 Sending 1 Stop condition Start condition Sending 0 Sending 1 Stop condition Servant receiver Servant receiver C S T R T 6 5 R 0 / C 8 w K Typical read/write cycle 7 0 S O C T P K C S T R T 6 5 R 0 / C 8 w K Typical read/write cycle 7 0 S O C T P K start condition 7-bit address R/W 8-bit data 7