Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CMP3006 Embedded Systems Programming Lecture 9: Interfacing with I2C, Lecture notes of Embedded Systems Programming

its for cmp3006 and 3010 some of the university notes it will be help

Typology: Lecture notes

2022/2023

Uploaded on 06/17/2023

fahd-2
fahd-2 🇹🇷

6 documents

1 / 34

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CMP3006
EMBEDDED
SYSTEMS
PROGRAMMING
LECTURE 9 INT E RFACING: I2C
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22

Partial preview of the text

Download CMP3006 Embedded Systems Programming Lecture 9: Interfacing with I2C and more Lecture notes Embedded Systems Programming in PDF only on Docsity!

CMP

EMBEDDED

SYSTEMS

PROGRAMMING

LECTURE 9 INTERFACING: I2C

Atmega 328 Pinout

I2C …

Master Transmit CLK ( transmitter or receiver)

Receiver does not change the level of SDA unless it wants to generate ACK

Note: Receiver can be Master or Slave

Bit Format

Each data bit transferred on the SDA line is synchronized by a high-to-low pulse

of clock on the SCL line.

Data line can change only when the clock line is low. Stop and Start conditions

are exceptions.

Repeated Start

If a master,which has the control of the bus, wishes to initiate a new transfer

and does not want to release the bus before starting the new transfer, it issues a

new START condition between a pair of START and STOP conditions.

Typical data transmission

Packet Format

Packet Types:

 Address Packet

 Data Packet

Address packet

Started by a Start Condition

 7 bits address, MSB first

 Define R/W

 ACK or NACK

Clock Stretching

If an addressed slave device is not ready to process more data, it will stretch

the clock by holding the clock line (SCL) low after receiving (or sending) a bit of

data.

Arbitration

it is possible that two or more masters initiate a transmission at about the

same time

 Each transmitter has to check the level of the bus and compare it with the level it expects

 if it doesn't match, that transmitter has lost the arbitration, and will switch to slave mode

I

C unit in AVR

Bus Interface Unit

 detects and generates START, REPEATED START and STOP conditions.

 detects arbitration

 controls sending or receiving ACK transfers packets of data or address.

Bit Rate Generation Unit

 controls the frequency of the system clock (SCL) when operating in a master mode

I

C unit in AVR

Address Match Unit

 Compares the received address byte with the 7-bit address in TWI address register and

informs the control unit upon an address match.

Control Unit

 controls the TWI module and generates responses according to settings in the TWI control

register

 sets the contents of the status register

 according to current state.

TWAR (TWI Address Register)

TWA6-0 (TWI slave Address)

TWGCE (TWI General Call Recognition Enable bit)

◦ 1: Answer to general call

TWI Control Register

TWINT (TWI Interrupt Flag)

TWEA (TWI Enable Acknowledge Bit)

 1:ACK, 0:NACK

TWSTA (TWI Start condition bit)

TWSTO (TWI Stop condition bit)

TWWC (TWI Write Collision flag)

TWEN (TWI Enable bit)

TWIEN (TWI Interrupt Enable)