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

Similar documents
spi 1 Fri Oct 13 13:04:

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

Understanding SPI with Precision Data Converters

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

Raspberry Pi - I/O Interfaces

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

2-Wire, 5-Bit DAC with Three Digital Outputs

Microcontrollers and Interfacing

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

< W3150A+ / W5100 Application Note for SPI >

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

Serial Peripheral Interface (SPI)

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

DS1306. Serial Alarm Real Time Clock (RTC)

DS75 Digital Thermometer and Thermostat

1.3inch OLED User Manual

Design with Microprocessors

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

CprE 488 Embedded Systems Design. Lecture 4 Interfacing Technologies

Growing Together Globally Serial Communication Design In Embedded System

SILICON MICROSTRUCTURES

EE 308 Spring Using the 9S12 SPI

DS WIRE INTERFACE 11 DECOUPLING CAP GND

DS1305 Serial Alarm Real Time Clock (RTC)

Digital Thermometer and Thermostat

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

ECE 4510/5530 Microcontroller Applications Week 10

Serial Buses in Industrial and Automotive Applications

Lecture 25 March 23, 2012 Introduction to Serial Communications

Microcontroller basics

FPGA Implementation Of SPI To I2C Bridge

DS1845 Dual NV Potentiometer and Memory

GT24C02. 2-Wire. 2Kb Serial EEPROM (Smart Card application)

DS1305EN. Serial Alarm Real-Time Clock

INTEGRATED CIRCUITS. PCA bit I 2 C and SMBus I/O port with interrupt. Product data sheet Supersedes data of 2004 Jul 27.

TOP VIEW CLOCK GENERATOR A1 A2 GND CPU SPEED SELECT

PART IN+ IN- TX_DISABLE TX_FAULT BIAS SET BIASMAX 2 APCSET 2 MODSET 2 MOD SET PC_MON BS_MON

PARALLEL COMMUNICATIONS

Lecture 5: Computing Platforms. Asbjørn Djupdal ARM Norway, IDI NTNU 2013 TDT

Interfacing Techniques in Embedded Systems

Part 1 Using Serial EEPROMs

DS1306 Serial Alarm Real-Time Clock

Lecture 14 Serial Peripheral Interface

DS1305EN. Serial Alarm Real-Time Clock

Preliminary Data MOS IC. Type Ordering Code Package SDA Q67100-H5092 P-DIP-8-1

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

or between microcontrollers)

+Denotes a lead(pb)-free/rohs-compliant package.

Freescale Semiconductor, Inc.

DS1682 Total-Elapsed-Time Recorder with Alarm

DESIGNING OF INTER INTEGRATED CIRCUIT USING VERILOG

Introduction to I2C & SPI. Chapter 22

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

Section 16. Basic Sychronous Serial Port (BSSP)

DS Wire Digital Thermometer and Thermostat

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

Arduino Uno R3 INTRODUCTION

12 Push-Pull Outputs and 4 Inputs

Microcontrollers and Interfacing week 10 exercises

Universität Dortmund. IO and Peripheral Interfaces

Fremont Micro Devices, Inc.

DS1625. Digital Thermometer and Thermostat FEATURES PIN ASSIGNMENT

ECE 471 Embedded Systems Lecture 20

DS1305. Serial Alarm Real Time Clock (RTC) FEATURES PIN ASSIGNMENT ORDERING INFORMATION

ORDERING INFORMATION. OPERATION Measuring Temperature A block diagram of the DS1621 is shown in Figure 1. DESCRIPTION ORDERING PACKAGE

White Paper Using the MAX II altufm Megafunction I 2 C Interface

LB5900 Series Power Sensor SPI & I2C Interface Guide

and 8 Open-Drain I/Os

Menu. What is SPI? EEL 3744 EEL 3744 SPI

Preliminary Data MOS IC. Type Ordering Code Package SDA Q67100-H5096 P-DIP-8-1

Real Time Embedded Systems. Lecture 1 January 17, 2012

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

SPI (Serial & Peripheral Interface)

Nuvoton NCT5655Y/W. 16-bit I 2 C-bus and SMBus GPIO controller with interrupt. Revision: 1.0 Date: May, 2016 NCT5655Y/W

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

How to Implement I 2 C Serial Communication Using Intel MCS-51 Microcontrollers

ST1633. Datasheet. Capacitive Touch Screen Controller. Version /11/17

Temperature Sensor TMP2 PMOD Part 1

SPI: Serial Peripheral Interface

Microcontroller interfaces

DS1855 Dual Nonvolatile Digital Potentiometer and Secure Memory

GT24C256 2-WIRE. 256K Bits. Serial EEPROM

DS1676 Total Elapsed Time Recorder, Erasable

Implementation of MCU Invariant I2C Slave Driver Using Bit Banging

I 2 C Port Expander with Eight Inputs. Features

PT7C4563 Real-time Clock Module (I2C Bus)

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

FM24CL04 4Kb FRAM Serial Memory

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

DS1305 Serial Alarm Real-Time Clock

RL78 Serial interfaces

HDI Series Amplified pressure sensors

Features. Ordering Information. Selector Guide. Applications. Pin Configurations. I 2 C Port Expander with 8 Open-Drain I/Os

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

Embedded Workshop 10/28/15 Rusty Cain

GT24C WIRE. 1024K Bits. Serial EEPROM

Microcontroller Systems. ELET 3232 Topic 23: The I 2 C Bus

Digital Thermometer and Thermostat

DS1631/DS1631A/DS1731 High-Precision Digital Thermometer and Thermostat

TB2669. I²C Slave Mode. Introduction. Author: Christopher Best, Microchip Technology Inc.

Transcription:

Embedded Systems and Software Serial Interconnect Buses I 2 C (SMB) and SPI I2C, SPI, etc. Slide 1

Provide low-cost i.e., low wire/pin count connection between IC devices There are many of serial bus standards I2C SMB SPI Microwire Maxim 3-wire Maxim/Dallas 1-wire CAN etc. Purpose of Serial Interconnect Buses We will focus on I 2 C and SPI I2C, SPI, etc. Slide 2

Overview Generic Serial Interconnect Bus Devices on bus. Can be several micros, one micro + peripherals, or multiple micros and one or more peripherals Pullup resistors ensure idle state of bus is HIGH. Devices pull line low when signaling. Wired-OR arrangement Bus. 1, 2, or 3 wires. This bus has 2 lines: Data and Clock. Bus carries data and commands. I2C, SPI, etc. Slide 3

SPI Devices D/A Converters Barometric Pressure SD Card EEPROMs I2C, SPI, etc. Slide 4

SPI Devices Ethernet Compass I2C, SPI, etc. Slide 5

SPI Devices FM Radio Chip FM Radio Module I2C, SPI, etc. Slide 6

I2C Devices BlinkM is a Smart LED, a networkable and programmable full-color RGB LED for hobbyists, industrial designers, and experimenters. MCP4725 is an I2C controlled Digital-to-Analog converter (DAC). A DAC allows a microcontroller to output analog values like a sine wave. Digital to analog converters are used sound generation, musical instruments, filtering, etc. I2C, SPI, etc. Slide 7

I2C Devices Honeywell HMC6352 Compass Module Breakout board for the Analog Devices 7746 capacitance sensor. I2C, SPI, etc. Slide 8

I2C Devices The TCM8240MD is a high quality, very small 1.3 mega-pixel color camera from Toshiba with the standard data + I2C interface. Breakout board using the AR1010 IC from Airoha. This FM receiver uses a simple command set over an I2C or SPI interface. This camera is also unique in that it offers on-board JPEG compression. I2C, SPI, etc. Slide 9

TWI Hardware on ATmega88PA ATmega88PA The ATmega88PA controller has dedicated TWI hardware. These pins provide access to the hardware One can also implement a Two-Wire serial interface in software on other pins. In other words, by bit-banging. I2C, SPI, etc. Slide 10

Commonly Encountered Terminology Term Transmitter Receiver Master Slave Multi-Master Arbitration Synchronization Description The device which sends the data to the bus. The device which receives the data from the bus. The device which initiates a transfer, generates clock signals and terminates a transfer. The device addressed by a master. More than one master can attempt to control the bus. Only one master can control the bus. Procedure to sync. the clock signal. I2C, SPI, etc. Slide 11

I 2 C (Inter-IC) I 2 C, Eye-Square-See, I2C, Eye-Two-See Two-wire serial bus protocol developed by Philips Semiconductors ~ 20 years ago Enables peripheral ICs to communicate using simple communication hardware Data transfer rates up to 100 kbits/s and 7-bit addressing possible in normal mode 3.4 Mbits/s and 10-bit addressing in fast-mode Common devices capable of interfacing to I 2 C bus: EPROMS, Flash, and some RAM memory, real-time clocks, watchdog timers, and microcontrollers Many microcontrollers, including ATmega88PA, have Two-Wire Interface (TWI) hardware AVR s TWI can be used to implement I2C, SMB, etc. I2C, SPI, etc. Slide 12

I2C The I2C-bus is a multi-master bus. This means that more than one device capable of controlling the bus can be connected to it. Masters are usually microcontrollers, slaves are peripherals We will use only one master (Atmega88PA) and one slave (RTC) I2C, SPI, etc. Slide 13

I2C Structure Master controls the bus, typically a microcontroller Pull-up resistors, ensure that by default, lines are high. We will use 4.7K resistors Slave responds to master(s), typically sensors, memory, etc. We will use one slave, a real-time clock (RTC) I2C, SPI, etc. Slide 14

I2C Structure Serial Clock Serial Data I2C, SPI, etc. Slide 15

I2C RTC Used in Lab 5 PCF8583 Clock/calendar with 240 8-bit RAM Power Supply Note: the part has a built-in capacitors for the oscillator, so we don t have to supply them externally I2C, SPI, etc. Slide 16

PCF8583 Pin Functions Power Supply One can configure the part so that this pin periodically goes low, or goes low when an alarm goes of, or do nothing. We will not use this pin. Partially determines the RTC address on the bus (see data sheet). I2C Bus Lines It can be 1 or 0, we choose 0 I2C, SPI, etc. Slide 17

I2C RTC Used in Lab 5 PCF8583 Clock/calendar with 240 8-bit RAM Notice, this does not use much current, one reason is because the clock frequency is low: 32.768 khz I2C, SPI, etc. Slide 18

I2C RTC Used in Lab 5 I2C, SPI, etc. Slide 19

I2C RTC Used in Lab 5 Register addresses. This is located within the RTC I2C, SPI, etc. Slide 20

I2C RTC Used in Lab 5 Control register determines behavior: use as an event counter, or a clock, 32.768 khz or 50 Hz time base, I2C, SPI, etc. Slide 21

I2C RTC Used in Lab 5 Registers contain the current time I2C, SPI, etc. Slide 22

I2C RTC Used in Lab 5 One can use the IC as a timer to time event durations I2C, SPI, etc. Slide 23

I2C RTC Used in Lab 5 One can use the part as an alarm clock. When alarm goes off pull INT line low I2C, SPI, etc. Slide 24

I2C RTC Used in Lab 5 Few bytes of additional RAM. One can use this for IDs, scratchpad, I2C, SPI, etc. Slide 25

I2C RTC Used in Lab 5 Select device s address on I2C bus I2C, SPI, etc. Slide 26

I2C RTC Used in Lab 5 IC2 Interface I2C, SPI, etc. Slide 27

I2C Protocol Both data and clock lines remain HIGH when the bus is not busy. A HIGH-to-LOW transition of the data line, while the clock is HIGH is defined as the start condition (S). A LOW-to-HIGH transition of the data line while the clock is HIGH is defined as the stop condition (P). I2C, SPI, etc. Slide 28

Acknowledgement on the I2C Bus Each byte of eight bits is followed by an acknowledge bit (ACK). Upon transmission of the 8 th bit, the master releases the SDA line, which goes HIGH, the master generates an ACK clock pulse, and the slave acknowledges by pulling the SDA line low. A master receiver must generate an acknowledge after the reception of each byte that has been clocked out of the slave transmitter. (master) MSB (slave) Also, a master receiver must generate an acknowledge after the reception of each byte that has been clocked out of the slave transmitter. I2C, SPI, etc. Slide 29

Acknowledgement on the I2C Bus A master receiver must signal an end of data to the transmitter by not generating an acknowledge on the last byte that has been clocked out of the slave (NACK). In this event, the transmitter must leave the data line HIGH to enable the master to generate a stop condition. (master) MSB (slave) I2C, SPI, etc. Slide 30

Addressing on the I2C Bus Before any data is transmitted on the I2C-bus, the device which should respond is addressed first. The addressing is always carried out with the first byte transmitted after the start procedure. This part of the address is determined by the manufacturer of the PCF8583, and is fixed. I2C, SPI, etc. Slide 31

Addressing on the I2C Bus Before any data is transmitted on the I2C-bus, the device which should respond is addressed first. The addressing is always carried out with the first byte transmitted after the start procedure. This part of the address is determined by the state of the IC s A0 pin It can be 1 or 0, we choose 0 I2C, SPI, etc. Slide 32

Addressing on the I2C Bus Before any data is transmitted on the I2C-bus, the device which should respond is addressed first. The addressing is always carried out with the first byte transmitted after the start procedure. This bit determines if we are reading ( = 1) from or writing to (= 0) to the devices I2C, SPI, etc. Slide 33

I2C Structure SCL SDA Microcontroller (master) EEPROM (slave) Temp. Sensor (slave) LCDcontroller (slave) < 400 pf Addr=0x01 Addr=0x02 Addr=0x03 SDA SDA SDA SDA SCL SCL SCL SCL Start condition Sending 0 Sending 1 Stop condition From Slave From receiver SDA SCL S T A R T A 6 A 5 A 0 R / w A C K D 8 D 7 D 0 A C K S T O P Start condition 7-bit address R/W 8-bit data I2C, SPI, etc. Slide 34

PCF8583 Control Status Register I2C, SPI, etc. Slide 35

PCF8583 Register Arrangement Values are stored in in BCD What does BCD mean? Answer Binary-Coded Decimal. There are two variants: Unpacked and packed Example 12d = 0x0C = 0000 1100b Unpacked BCD: Packed BCD: 0000 0001 0000 0010 1 2 0001 0010 1 2 I2C, SPI, etc. Slide 36

PCF8583 Master transmits to slave receiver (WRITE) mode. I2C, SPI, etc. Slide 37

PCF8583 Master reads after setting word address (write word address; READ data). I2C, SPI, etc. Slide 38

PCF8583 Master reads slave immediately after first byte (READ mode). I2C, SPI, etc. Slide 39

I2C Bus Timing f scl = 100 khz SCL clock frequency I2C, SPI, etc. Slide 40

I2C Bus Timing t SU;STA = 4.7 μs min START setup time I2C, SPI, etc. Slide 41

I2C Bus Timing t BUF = 4.7 μs min Bus free time I2C, SPI, etc. Slide 42

I2C Bus Timing t HD;STA = 4 μs min START Hold Time I2C, SPI, etc. Slide 43

I2C Bus Timing t LOW = 4.7 μs min SCL LOW time I2C, SPI, etc. Slide 44

I2C Bus Timing t HIGH = 4.7 μs min SCL HIGH time I2C, SPI, etc. Slide 45

I2C Bus Timing t t = 1.0 μs max t f = 0.3 μs max SDA and SCL rise and fall times I2C, SPI, etc. Slide 46

I2C Bus Timing t SU;DAT = 250 ns min Data setup time I2C, SPI, etc. Slide 47

I2C Bus Timing t VD;DAT = 3.4 μs SCL LOW to data out valid I2C, SPI, etc. Slide 48

I2C Bus Timing t SU;STO = 3.4 μs STOP setup time I2C, SPI, etc. Slide 49

Actual Bus Signals SDA SCL SDA (above) and SCL (below) with R p = 10 kω and C p = 300 pf. The SCL clock runs at 100 khz (nominal). One can improve rise- and fall times by decreasing resistance values I2C, SPI, etc. Slide 50

Serial Peripheral Interface (SPI) Originally developed by Motorola Synchronous, serial protocol Data timing is controlled by an explicit clock signal (SCK) Master-slave Master device controls the clock Bi-directional data exchange Data clocked into and out-of device at same time I2C, SPI, etc. Slide 51

SPI Devices D/A Converters Barometric Pressure SD Card EEPROMS I2C, SPI, etc. Slide 52

SPI Devices Ethernet Compass I2C, SPI, etc. Slide 53

SPI Devices FM Radio Chip FM Radio Module I2C, SPI, etc. Slide 54

SPI signals SS (CS) (Slave Select, Chip Select) When SS is low the slave is enabled SCK (Serial Clock) Controls the sending and reading of data SD0 (Serial Data Out) Carries data OUT of the device SDI (Serial Data In) Carries data INTO the device I2C, SPI, etc. Slide 55

Connecting Multiple SPI Devices arbitrary SDO SDI SCK pins AVR or other Micro (Master) SS SDO SDI SCK SPI Slave 1 SS SDO SDI SCK SPI Slave K I2C, SPI, etc. Slide 56

SPI on AVRs AVR microcontrollers have built-in hardware support for SPI AVRs can be bus masters (common), but one can also configure them to be bus slaves AVRs use SPI pins for ISP What is ISP? I2C, SPI, etc. Slide 57

SPI on AVRs AVR microcontrollers have built-in hardware support for SPI SCK Master Clock Output, Slave Clock I2C, SPI, etc. Slide 58

SPI on AVRs AVR microcontrollers have built-in hardware support for SPI MISO SPI Bus Master Input, Slave Output) I2C, SPI, etc. Slide 59

SPI on AVRs AVR microcontrollers have built-in hardware support for SPI MOSI SPI Bus Master Output, Slave Input I2C, SPI, etc. Slide 60

SPI on AVRs AVR microcontrollers have built-in hardware support for SPI SS SPI Bus Master Slave Select If AVR is configured as slave and one is using SPI hardware for SPI, then this would be used for selecting the AVR slave I2C, SPI, etc. Slide 61

SPI on AVRs Port pins I2C, SPI, etc. Slide 62

SPI on AVRs SPI Control Register I2C, SPI, etc. Slide 63

SPI on AVRs SPI Status Register I2C, SPI, etc. Slide 64

SPI on AVRs One can configure SPI hardware to generate interrupts I2C, SPI, etc. Slide 65

SPI on AVRs SPDR SPI Data Register. This is where our program reads/writes data I2C, SPI, etc. Slide 66

SPI Data Loop SPDR Master Slave I2C, SPI, etc. Slide 67

SPI Data Loop Internal shift register SPDR Master Slave I2C, SPI, etc. Slide 68

SPI Data Loop SPDR SPI Data Register. This is where our program reads/writes data SPDR Master Slave Master selects slave on bus to talk to I2C, SPI, etc. Slide 69

SPI Data Loop SPDR SPI Data Register. This is where our program reads/writes data SPDR Master Slave Master generates the clock that controls the data transfer I2C, SPI, etc. Slide 70

SPI Modes SPI has several modes that determine when data is valid with respect to the clock Caution: read SPI peripheral (i.e., RTC, sensor, ) datasheets carefully, and make sure your AVR uses the same mode I2C, SPI, etc. Slide 71

SPI Transfer Modes SPI Transfer Format with CPHA = 0 SPI Transfer Format with CPHA = 1 I2C, SPI, etc. Slide 72

SPI Transfer Modes SPI Transfer Format with CPHA = 0 SPI Transfer Format with CPHA = 1 I2C, SPI, etc. Slide 73

SPI Transfer Modes SPI Transfer Format with CPHA = 0 SPI Transfer Format with CPHA = 1 I2C, SPI, etc. Slide 74

SPI Transfer Modes SPI Transfer Format with CPHA = 0 SPI Transfer Format with CPHA = 1 I2C, SPI, etc. Slide 75

SPI Transfer Modes SPI Transfer Format with CPHA = 0 SPI Transfer Format with CPHA = 1 I2C, SPI, etc. Slide 76

SPI Transfer Modes SPI Transfer Format with CPHA = 0 SPI Transfer Format with CPHA = 1 I2C, SPI, etc. Slide 77

Configuring SPI SPIE: SPI Interrupt Enable This bit causes the SPI interrupt to be executed if SPIF bit in the SPSR register is set and the if the Global Interrupt Enable bit in SREG is set. I2C, SPI, etc. Slide 78

Configuring SPI SPE: SPI Enable When the SPE bit is written to one, the SPI is enabled. This bit must be set to enable any SPI operations. I2C, SPI, etc. Slide 79

Configuring SPI DORD: Data Order When the DORD bit is written to one, the LSB of the data word is transmitted first. When the DORD bit is written to zero, the MSB of the data word is transmitted first. I2C, SPI, etc. Slide 80

Configuring SPI MSTR: Master/Slave Select This bit selects Master SPI mode when written to one, and Slave SPI mode when written logic zero. If SS is configured as an input and is driven low while MSTR is set, MSTR will be cleared, and SPIF in SPSR will become set. The user will then have to set MSTR to reenable SPI Master mode. I2C, SPI, etc. Slide 81

Configuring SPI CPOL: Clock Polarity When this bit is written to one, SCK is high when idle. When CPOL is written to zero, SCK is low when idle. I2C, SPI, etc. Slide 82

Configuring SPI CPHA: Clock Phase The settings of the Clock Phase bit (CPHA) determine if data is sampled on the leading (first) or trailing (last) edge of SCK. I2C, SPI, etc. Slide 83

Configuring SPI CPHA: Clock Phase The settings of the Clock Phase bit (CPHA) determine if data is sampled on the leading (first) or trailing (last) edge of SCK. I2C, SPI, etc. Slide 84

I2C, SPI, etc. Slide 85