Lecture 27: LM3S9B96 Microcontroller – Inter- Integrated Circuit (I 2 C) Interface.

Slides:



Advertisements
Similar presentations
I2C bus Inter Integrated Circuits bus by Philips Semiconductors
Advertisements

I/O Organization popo.
INPUT-OUTPUT ORGANIZATION
ECT 357 Ch 18 UART. Today’s Quote: Be careful that your marriage doesn’t become a duel instead of a duet. Be careful that your marriage doesn’t become.
Embedded Systems I2CI2C. Feature 3 wire GND SCL(clock) SDA(data) All devices share the same bus wire Using wire and, each device gain access to bus (become.
Serial Interfaces, Part Deux -I 2 C and SPI December 4, 2002 Presented by Eugene Ho.
Lecture 8: Serial Interfaces
CS-334: Computer Architecture
FIU Chapter 7: Input/Output Jerome Crooks Panyawat Chiamprasert
Refer to Chapter 6, 9 in the reference book
7-1 Digital Serial Input/Output Two basic approaches  Synchronous shared common clock signal all devices synchronised with the shared clock signal data.
Configuration. Mirjana Stojanovic Process of loading bitstream of a design into the configuration memory. Bitstream is the transmission.
I2CI2C CS-423 Dick Steflik. Inter-Integrated Circuit Developed and patented by Philips for connecting low speed peripherals to a motherboard, embedded.
Two Wire Interface Another popular serial peripheral interface bus -More flexible than SPI -Master and slave modes supported -7-bit slave address -400khz.
Unit-5 CO-MPI autonomous
Haptic Belt team Informational Presentation.  I 2 C is a form of control bus (multi-master) which allows communication between multiple integrated circuits.
INPUT-OUTPUT ORGANIZATION
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 10: Serial buses Oct 6, 2011.
SERIAL BUS COMMUNICATION PROTOCOLS
1 © Unitec New Zealand I2C Lecture 10 Date: - 2 Nov, 2011 Embedded Hardware ETEC 6416.
Computer Architecture Lecture 08 Fasih ur Rehman.
Serial Peripheral Interface (SPI) Bus. SPI Bus There is no official specification for the SPI bus. It is necessary to consult the data sheets of the devices.
Serial Peripheral Interface Module MTT M SERIAL PERIPHERAL INTERFACE (SPI)
The University of New Hampshire InterOperability Laboratory Serial ATA (SATA) Protocol Chapter 10 – Transport Layer.
Lecture 111 Lecture 11: Lab 3 Overview, the ADV7183B Video Decoder and the I 2 C Bus ECE 412: Microcomputer Laboratory.
LSU 10/22/2004Serial I/O1 Programming Unit, Lecture 5.
VERIFICATION OF I2C INTERFACE USING SPECMAN ELITE By H. Mugil Vannan Experts Mr. Rahul Hakhoo, Section Manager, CMG-MCD Mr. Umesh Srivastva, Project Leader.
Embedded Bus – i2c David E. Culler Lab 2 Feb 2, 2015
Chapter 10: Input / Output Devices Dr Mohamed Menacer Taibah University
Lecture 26: LM3S9B96 Microcontroller – Universal Asynchronous Receivers/Transmitters.
Input/Output mechanisms
Lecture 29: LM3S9B96 Microcontroller – Pulse Width Modulator (PWM)
7/23 Inter-chip Serial Communication: SPI and I 2 C Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee.
Lecture 20: Communications Lecturers: Professor John Devlin Mr Robert Ross.
Lecture 9 I2C NCHUEE 720A Lab Prof. Jichiang Tsai.
Computer Architecture Lecture10: Input/output devices Piotr Bilski.
DEVICES AND COMMUNICATION BUSES FOR DEVICES NETWORK
Lecture 25: LM3S9B96 Microcontroller – Watchdog Timer.
The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – Universal Asynchronous Receivers/Transmitters Refer to Chapter 13 in the reference book “Stellaris®
Advanced Microprocessor1 I/O Interface Programmable Interval Timer: 8254 Three independent 16-bit programmable counters (timers). Each capable in counting.
PCA9557: REMOTE 8-BIT I 2 C AND SMBus LOW- POWER I/O EXPANDER.
I2C Master Core Simulation Environment. I2C Master Core Requirements Coverage (*) Requirement I2C IP RS-906: The I2C IP shall define the period of time,
1 Synchronous Serial IO Send a separate clock line with data –SPI (serial peripheral interface) protocol –I 2 C (or I2C) protocol Encode a clock with data.
ATtiny23131 A SEMINAR ON AVR MICROCONTROLLER ATtiny2313.
The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – Pulse Width Modulator (PWM) Refer to Chapter 21 in the reference book “Stellaris® LM3S9B96 Microcontroller.
Refer to Chapter 15 in the reference book
©2008 R. Gupta, UCSD COSMOS Summer 2008 Peripheral Interfaces Rajesh K. Gupta Computer Science and Engineering University of California, San Diego.
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
Lecture 22: LM3S9B96 Microcontroller – SysTick and General-Purpose Timers.
The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – Watchdog Timers Refer to Chapter 11 in the reference book “Stellaris® LM3S9B96 Microcontroller.
Communicating. The ATmega16 communicates through one of the following ways: Serial Peripheral Interface (SPI) Universal Synchronous and Asynchronous serial.
میکرو کنترلرهای AVR Serial Interfaces, I2C and SPI
Serial mode of data transfer
Outline Analog to digital conversion (ADC) of NuMaker TRIO
Two Wire Interface Another popular serial peripheral interface bus
Refer to Chapter 16 in the reference book
Inter-IC Bus (I C) 2.
Chapter 11: Inter-Integrated Circuit (I2C) Interface
(Inter-IC bus) By Tejaswini Gadicherla
Two Wire Interface (TWI)
EE 107 Fall 2017 Lecture 7 Serial Buses – I2C Direct Memory Access
I2C Protocol and RTC Interfacing
I2C PROTOCOL SPECIFICATION
Communication Lines Fundamentals.
I2C Protocol and RTC Interfacing
I2C Protocol and RTC Interfacing
Presentation transcript:

Lecture 27: LM3S9B96 Microcontroller – Inter- Integrated Circuit (I 2 C) Interface

Stellaris® LM3S9B96 Microcontroller Data Sheet Chapter 16 Inter-Integrated Circuit (I 2 C) Interface

zThe Inter-Integrated Circuit (I 2 C) bus : zbi-directional data transfer via a two-wire design: a serial data line SDA and a serial clock line SCL zinterfaces to external I 2 C devices: serial memory, networking devices, LCDs, tone generators

Inter-Integrated Circuit (I 2 C) Interface zThe LM3S9B96 microcontroller includes two I 2 C modules: zSupports both transmitting and receiving data as either a master or a slave zFour I 2 C modes: Master/Slave transmit/receive zTwo transmission speeds: Standard (100 Kbps) and Fast (400 Kbps) zMaster and slave interrupt generation zMaster with arbitration and clock synchronization, multi- master support, and 7-bit addressing mode

Block Diagram

Functional Description zThe I 2 C bus uses only two signals: SDA and SCL, named I2CSDA and I2CSCL on Stellaris microcontrollers zThe bus is considered idle when both lines are High zEvery transaction on the I2C bus is nine bits long, i.e., 8 data bits (MSB first) and 1 single acknowledge bit zThe number of bytes in one transfer is unrestricted zWhen a receiver cannot receive another complete byte, it can hold the clock line SCL Low and force the transmitter into a wait state zThe data transfer continues when the receiver releases the clock SCL

I 2 C Bus Configuration

START and STOP Conditions zThe protocol of the I 2 C bus defines two states to begin and end a transaction: START and STOP zA High-to-Low transition on the SDA line while the SCL is High is defined as a START condition zA Low-to-High transition on the SDA line while SCL is High is defined as a STOP condition

Data Format with 7-Bit Address zAfter the START condition, a slave address is transmitted zThe address is 7 bits long and followed by a direction bit (R/S bit in the I2C Master Slave Address (I2CMSA) register) zR/S is cleared, a transmit operation (send) zR/S is set, a request for data (receive) zA data transfer is always terminated by a STOP condition generated by the master zA master can initiate communications with another device on the bus by generating a repeated START condition and addressing another slave without first generating a STOP condition.

Data Format with 7-Bit Address zA zero in the R/S position of the first byte means that the master transmits (sends) data to the selected slave, and a one in this position means that the master receives data from the slave

Data Validity zThe data on the SDA line must be stable during the high period of the clock zThe data line can only change when SCL is Low

Arbitration

Acknowledge zAll bus transactions have a required acknowledge clock cycle zDuring the acknowledge cycle, the transmitter (master or slave) releases the SDA line zTo acknowledge the transaction, the receiver must pull down SDA during the acknowledge clock cycle zWhen a slave receiver does not ack the slave address, the master can generate a STOP condition and abort the current transfer. zW hen the master acting as a receiver, it is responsible for acknowledging each transfer made by the slave zThe master receiver controls the number of bytes in the transfer by not generating an acknowledge on the last data byte; slave transmitter will give up the data line

Available Speed Modes zThe I 2 C bus can run in either Standard mode (100 kbps) or Fast mode (400 kbps) zThe selected mode should match the speed of the other I 2 C devices on the bus zThe mode is selected by using a value in the I2C Master Timer Period (I2CMTPR) register zThe I2C clock rate is determined by the parameters: zCLK_PRD is the system clock period zSCL_LP is the low phase of SCL (fixed at 6) zSCL_HP is the high phase of SCL (fixed at 4) zTIMER_PRD is the programmed value in the I2CMTPR register

Available Speed Modes SCL_PERIOD = 2 × (1 + TIMER_PRD) × (SCL_LP + SCL_HP) × CLK_PRD zFor example: CLK_PRD = 50 ns, TIMER_PRD = 2, SCL_LP=6, SCL_HP=4 Therefore, the SCL frequency is : 1/SCL_PERIOD = 333 Khz

Interrupts zThe I2C can generate interrupts when the following conditions are observed: zMaster transaction completed zMaster transaction error zSlave transaction received zSlave transaction requested zStop condition on bus detected zStart condition on bus detected zThe I2C master and I2C slave modules have separate interrupt signals zA module can generate interrupts for multiple conditions but only one single interrupt signal is sent to the interrupt controller

I 2 C Master Interrupts zWhen a transaction completes or when an error occurs during a transaction zTo enable the I 2 C master interrupt, the IM bit in the I2C Master Interrupt Mask (I2CMIMR) register must be set zWhen an interrupt condition is met, software must check the ERROR bit in the I2C Master Control/Status (I2CMCS) register to verify that an error didn't occur zThe interrupt is cleared by writing a 1 to the IC bit in the I2C Master Interrupt Clear (I2CMICR) register zIf the application doesn't require the use of interrupts, the raw interrupt status is always visible via the I2C Master Raw Interrupt Status (I2CMRIS) register

I 2 C Slave Interrupts zWhen data has been received or requested zThis interrupt is enabled by setting the DATAIM bit in the in the I2C Slave Interrupt Mask (I2CSIMR) register zSoftware determines whether the module should write (transmit) or read (receive) data from the I2C Slave Data (I2CSDR) register, by checking the RREQ and TREQ bits of the I2C Slave Control/Status (I2CSCSR) register zThe interrupt is cleared by setting the DATAIC bit in the I2C Slave Interrupt Clear (I2CSICR) register zIn addition, the slave module can generate an interrupt when a start and stop condition is detected (STARTIM and STOPIM bits in I2CSIMR) zIf the application doesn't require the use of interrupts, the raw interrupt status is always visible via the I2C Slave Raw Interrupt Status (I2CMRIS) register

Loopback Operation zThe I 2 C modules can be placed into an internal loopback mode for diagnostic or debug work zSet the LPBK bit in the I2C Master Configuration (I2CMCR) register zSDA and SCL signals from the master and slave modules are tied together

I 2 C Master Command Sequences

I 2 C Slave Command Sequences

Initialization and Configuration zThe following example shows how to configure the I 2 C module to transmit a single byte as a master: z1. Enable the I 2 C clock by writing a value of 0x to the RCGC1 register in the System Control module z2. Enable the clock to the appropriate GPIO module via the RCGC2 register in the System Control module z3. In the GPIO module, enable the appropriate pins for their alternate function using the GPIOAFSEL register z4. Enable the I 2 C pins for Open Drain operation z5. Configure the PMCn fields in the GPIOPCTL register to assign the I2C signals to the appropriate z6. Initialize the I2C Master by writing the I2CMCR register with a value of 0x

Initialization and Configuration z7. Set the desired SCL clock speed of 100 Kbps by writing the I2CMTPR register with the correct value: (System Clock/(2*(SCL_LP + SCL_HP)*SCL_CLK))-1; = (20MHz/(2*(6+4)*100000))-1; = 9 z8. Specify the slave address of the master and that the next operation is a Transmit by writing the I2CMSA register with a value of 0x , which sets the slave address to 0x3B z9. Place data (byte) to be transmitted in the data register by writing the I2CMDR register with the desired data z10. Initiate a single byte transmit of the data from Master to Slave by writing the I2CMCS register with a value of 0x (STOP, START, RUN) z11. Wait until the transmission completes by polling the I2CMCS register’s BUSBSY bit until it has been cleared.

Register Map zThe I 2 C’s base address: zI 2 C Master 0: 0x zI 2 C Slave 0: 0x zI 2 C Master 1: 0x zI 2 C Slave 1: 0x zTable 16-4 on page 701 lists the I 2 C interface registers. zFor detailed register descriptions, refer to Chapter 16.6