SlideShare a Scribd company logo
Inter-integrated Circuit (I2
C)
Protocol and
DS1307 RTC Interfacing
Presented by:-Bhargav Kakadiya (140070110006)
The I2
C Protocol
• Developed by Philips in late 1980s
• Version 1.0 published in 1992
– Supports standard (100 Kbps) and fast (400 Kbps) mode
• Version 2.0 published in 1998
– High-speed mode (3.4 Mbps) added
• Classifies devices into slave and master
• Allows multiple masters to be attached to the same bus
• The master device uses either a 7-bit or 10-bit address to specify
the slave device as its partner of data communication.
• Supports bi-directional data transfer
• Allows multiple masters (microcontrollers) to share the same
peripheral devices
I2
C Signal Level
• Float high and driven low
• Use the SCL signal to carry clock signal to synchronize
data transfer
• Use the SDA signal to carry data and address
• The SDA and SCL pins of I2
C devices (masters and
slaves) are open-drain and need external pull up
resistors.
• The resistors 2.2 KΩ and 1 K Ω are recommended for
100 Kbps and 400 Kbps baud rate.
+VDD
RP
RP
CLK1
OUT
CLK1
IN
Data1
OUT
Data1
IN
CLK2
OUT
CLK2
IN
Data2
OUT
Data2
IN
Device1 Device2
SDA line
SCL line
Figure 11.1Connecting standard- andfast-mode devices to theI2Cbus
Signal Components
• I2
C data transfer consists of 5 signal
components:
– Start (S)
– Stop (P)
– Repeated Start (R)
– Data
– Acknowledge (A)
SDA
SCL
Figure 11.2 I2C Start condition
Start Condition
• Used to indicate that a device would like to
transfer data on the I2
C bus
• Represented by the SDA line going low when
the clock (SCL) signal is high
• Will initialize the I2
C bus
SDA
SCL
Figure 11.3 Stop (P) condition
Stop Condition
• A condition that a device wants to release the I2
C bus
• Is represented by the SDA signal going high when the
SCL signal is high
• Once the stop condition is complete, both the SCL and
SDA signals are high. This is the idle bus.
SDA
SCL
Figure 11.4Restart condition
start condtion
data transfer restart
condition
Repeated Start (R) Condition
• A Start signal generated without first generating a Stop
condition to terminate the communication
• Used by the master to communicate with another slave
or change data transfer direction without releasing the
bus
• Also referred to as Restart condition
SDA
SCL
Figure 11.5 I2
Cbus dataelements
Note. Data bit is always stable when clock (SCL) is high
Data
• It represents the transfer of eight bits of information.
• Data on the SDA line is considered valid only when the SCL signal
is high.
• When the SCL signal is low, the data is allowed to change.
• The eight-bit data may be a control code, an address, or data.
SDA
SCL
Figure11.6 ACKcondition
SDA
SCL
Figure11.7 NACKcondition
Acknowledge (ACK) Condition
• Data transfer needs to be acknowledged either positively (A) or
negatively (NACK).
• A device acknowledges a byte it receives positively by bringing the
SDA line low during the ninth clock pulse of SCL.
• If the device allows the SDA line to float high, it is transmitting a
negative acknowledge (NACK).
Synchronization (1 of 2)
• All masters generate their clocks on the SCL line to transfer
messages on the I2C bus.
• A defined clock is needed for the bit-by-bit arbitration procedure to
take place.
• Most microcontrollers generate the SCL clock by counting down a
programmable reload value using the instruction clock signal.
• Clock synchronization occurs when multiple masters attempt to
drive the I2C bus and before the arbitration scheme can decide
which master is the winner.
• Clock synchronization is performed using the wired-AND connection
of I2C interfaces to the SCL line.
• The high-to-low transition on the SCL line causes the devices
concerned (masters) to start counting off their low period.
Synchronization (2 of 2)
• A master device that is counting off their low period will hold the SCL
line low until the counter is count down to 0. At this point, the device
will release the SCL line to high.
• If there are other devices holding the SCL low, then the SCL line will
remain low until all master devices have counted down to 0. At this
point, the SCL line will go high and all devices will start to count
high.
• The SCL line will be held low by the device with the longest low
period.
• By the same reasoning, the high period of the SCL signal is
determined by the device with the shortest high period.
wait
state
start counting
high period
counter
reset
CLK1
CLK2
SCL
Figure 11.8 Clock synchronization during the
arbitrationprocedure
Handshaking
• The clock synchronization mechanism can be used as a
handshake in data transfer.
• Slave device can hold the SCL line low after completion
of one byte transfer (9 bits).
• Slave halts the bus until it gets ready for the next
operation and then release the SCL line.
master 1 loses arbitration
Data 1 ≠ SDA
SCL
Data1
Data2
SDA
Figure 11.9 Arbitration procedure of two masters
Arbitration
• In the event two or more master devices attempt to begin a transfer at the
same time, an arbitration scheme is employed to force one or more masters
to give up the bus.
• The master devices continue to transmit data until one master attempts to
send a high while the other transmits a low.
• Since the SDA bus has open drain, the master device that attempts to send
a high will detect a low. At this point, it will stop driving the bus.
• The arbitration process does not slow down the winning master’s transfer
and no data gets lost.
A6 A5 A4 A3 A2 A1 A0 R/W
Figure 11.13a 7-bit I2C address
1 1 1 1 0 A9 A8 R/W A7 A6 A5 A4 A3 A2 A1 A0
Figure 11.13b 10-bit I2C address
I2
C Addressing Methods
• I2
C protocol allows master devices to use either the 7-bit and 10-bit
address to specify the slave device for data communication.
• The 7-bit addressing uses the upper 7 bits of the address byte for
address and the least significant bit to specify the data transfer
direction. The format is shown in Figure 11.13.
• The 10-bit addressing uses two bytes to carry the address
information.
– The bit 0 of the high byte is used to indicate the data transfer direction.
– The upper 7 bits have the pattern of 1111 0xx with xx representing the
most significant two address bits of the slave.
– The second byte carries the lower 8 address bits.
S Slave address R/W A Data A Data A/A P
data transferred
(n bytes + acknowledge)
'0' (write)
from master to slave
from slave to master
A = acknowledge (SDA low)
A = not acknowledge (SDA high)
S = start condition
P = stop condition
Figure 11.10 A master-transmitter addressing a slave receiver with a 7-bit address.
The transfer direction is not changed.
Data Transfer Format (7-bit Addressing) (1 of 2)
• Master transmitter to slave receiver – shown in Figure 11.10
• Master reads slave immediately after the first byte (address byte) –
shown in Figure 11.11
• Combined format. A master may transfer some data to the slave and
then generate a restart condition to read data from the slave or
send/read data to/from other slave-- shown in Figure 11.12.
S Slave address R/W A Data Data P
data transferred
(n bytes + acknowledge)
'1' (read)
Figure 11.11 A master reads a slave immediately after the first byte
AA
S Slave address R/W A Data Data
read or
write
Figure 11.12 Combined format
A/A R Slave address R/W A/A P
(n bytes +
ack.)
repeated
start
read or
write
A
(n bytes +
ack.)*
direction of
transfer may
change at this
point
* not shaded because
transfer direction of data
and acknowledge bits
depends on R/W bits
Data Transfer Format (7-bit Addressing) (2 of 2)
TWI
TWBR
TWBR selects the division factor for the bit rate generator. The bit
rate generator is a frequency divider which generates the SCL clock
frequency in the Master modes.
TWBR = Value of the TWI Bit Rate Register
TWPS = Value of the prescaler bits in the TWI Status Register
TWSR
Bits [7:3] – TWS: TWI Status
These five bits reflect the status of the TWI logic and the Two-wire Serial Bus. The
different status codes are described later in this section. Note that the value read from
TWSR contains both the 5-bit status value and the 2-bit prescaler value. The application
designer should mask the prescaler bits to zero when checking the Status bits. This
makes status checking independent of prescaler setting. This approach is used in this
datasheet, unless otherwise noted.
Bit 2 – Reserved Bit
This bit is reserved and will always read as zero.
Bits [1:0] – TWPS: TWI Prescaler Bits
These bits can be read and written, and control the bit rate prescaler.
TWCR
Bit 7 – TWINT: TWI Interrupt Flag
This bit is set by hardware when the TWI has finished its current job and expects
application software response. If the I-bit in SREG and TWIE in TWCR are set, the
MCU will jump to the TWI Interrupt Vector. While the TWINT Flag is set, the SCL
low period is stretched.
Bit 6 – TWEA: TWI Enable Acknowledge Bit
The TWEA bit controls the generation of the acknowledge pulse. If the TWEA bit is
written to one, the ACK pulse is generated
Bit 5 – TWSTA: TWI START Condition Bit
The application writes the TWSTA bit to one when it desires to become a master on
the Two wire Serial Bus. The TWI hardware checks if the bus is available, and
generates a START condition on the bus if it is free.
Bit 4 – TWSTO: TWI STOP Condition Bit
Writing the TWSTO bit to one in Master mode will generate a STOP condition on the
Two-wire Serial Bus. When the STOP condition is executed on the bus, the TWSTO
bit is cleared automatically.
Bit 3 – TWWC: TWI Write Collision Flag
The TWWC bit is set when attempting to write to the TWI Data Register –
TWDR when TWINT is low. This flag is cleared by writing the TWDR Register
when TWINT is high.
• Bit 2 – TWEN: TWI Enable Bit
The TWEN bit enables TWI operation and activates the TWI interface. When
TWEN is written to one, the TWI takes control over the I/O pins connected to
the SCL and SDA pins, enabling the slew-rate limiters and spike filters. If this bit
is written to zero, the TWI is switched off and all TWI transmissions are
terminated, regardless of any ongoing operation.
• Bit 1 – Reserved Bit
This bit is a reserved bit and will always read as zero.
• Bit 0 – TWIE: TWI Interrupt Enable
When this bit is written to one, and the I-bit in SREG is set, the TWI interrupt
request will be activated for as long as the TWINT Flag is high.
TWDR
These eight bits contain the next data byte to be transmitted, or the
latest data byte received on the Two-wire Serial Bus.
In Transmit mode, TWDR contains the next byte to be transmitted.
In Receive mode, the TWDR contains the last byte received.
TWAR
These seven bits constitute the slave address of the TWI unit.
The TWAR should be loaded with the 7-bit slave address (in the
seven most significant bits of TWAR) to which the TWI will
respond when programmed as a slave transmitter or receiver. In
multimaster systems, TWAR must be set in masters which can be
addressed as slaves by other masters.
1X1
2X2
3VBAT
4GND
8
7
6
5 SDA
SCL
SQWOUT
VCC
DS1307
Oscillator
and divider
X1 X2
square
wave out
SQWOUT
power
control
VCC
VBAT
GND
serial bus
interface
SCL
SDA
control
logic
address
register
RTC
RAM
(56x8)
Figure 11.27 DS1307 pin assignment and block diagram
The Serial Real-Time Clock DS1307
• Uses BCD format to represent the clock and calendar information
• Has 56 bytes to store critical information
• Clock calendar provides seconds, minutes, hours, day, date, month, and year information
• Operates in either the 24-hour or 12-hour format with AM/PM indicator
• Has built-in power sense circuit that detects power failure and automatically switches to the
battery supply
• The SQW output frequency may be 1 Hz, 4 KHz, 8 KHz, and 32 KHz.
$00
$07
$08
$3F
seconds
minutes
hours
day
date
month
year
control
RAM
56 x 8
Figure 11.28 DS1307 address map
$01
$02
$03
$04
$05
$06
CH 10 seconds seconds
10 minutes0
0
minutes
hours12
24
10 HR
A/P
10 HR
0 0 0 0 0 day
0 0
0 0 0
10 date
10
month
date
month
year10 year
out sqwe0 0 0 0 RS1 RS0
Figure 11.29 Contents of RTC registers
Bit 7 Bit 0
- Bit 6 of the hours register selects whether the 12-hour or 24-hour
mode is used.
- Bit 5 of the hours register selects whether the current time is AM or
PM if 12-hour mode is selected.
DS1307 Address Map
Interfacing with ATMega32
Table11.7 Squarewaveoutputfrequency
RS1 RS0 SQWoutputfrequency
0
0
1
1
0
1
0
1
1 Hz
4.096 KHz
8.192 KHz
32.768 KHz
DS1307 Control Register
• Bit 7 controls the output level of the SQWOUT pin when
the square output is disabled.
• The SQWE bit enables/disables the SQWOUT pin
output.
• Bits 1 and 0 select the output frequency of the SQWOUT
pin.
DS1307 Write Operation
DS1307 Read Operation
THANK YOU
Ad

More Related Content

What's hot (20)

SOC/ASIC Bus Standards
SOC/ASIC Bus StandardsSOC/ASIC Bus Standards
SOC/ASIC Bus Standards
ArchitecTerra Ltd.
 
I2C BUS PROTOCOL
I2C BUS PROTOCOLI2C BUS PROTOCOL
I2C BUS PROTOCOL
Kashyap Mandaliya
 
I2C-Bus Design and Verification Specs
I2C-Bus Design and Verification SpecsI2C-Bus Design and Verification Specs
I2C-Bus Design and Verification Specs
Mostafa Khamis
 
UART
UARTUART
UART
Somdatta Ganguly
 
Axi
AxiAxi
Axi
Vinchipsytm Vlsitraining
 
Unit 4 _ ARM Processors .pptx
Unit 4 _ ARM Processors .pptxUnit 4 _ ARM Processors .pptx
Unit 4 _ ARM Processors .pptx
VijayKumar201823
 
DDR SDRAMs
DDR SDRAMsDDR SDRAMs
DDR SDRAMs
Prankit Mishra
 
Apb
ApbApb
Apb
Azad Mishra
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
Sudhanshu Janwadkar
 
I2C BUS
I2C BUSI2C BUS
I2C BUS
p_ayal
 
Introduction about APB Protocol
Introduction about APB ProtocolIntroduction about APB Protocol
Introduction about APB Protocol
Pushpa Yakkala
 
Uart
UartUart
Uart
Aditee Apurvaa
 
Axi
AxiAxi
Axi
Azad Mishra
 
AXI Protocol.pptx
AXI Protocol.pptxAXI Protocol.pptx
AXI Protocol.pptx
Yazan Yousef
 
Double data rate (ddr)
Double data rate (ddr)Double data rate (ddr)
Double data rate (ddr)
Anderson Huang
 
AMBA Ahb 2.0
AMBA Ahb 2.0AMBA Ahb 2.0
AMBA Ahb 2.0
Akhil Srivastava
 
I2C introduction
I2C introductionI2C introduction
I2C introduction
SUNODH GARLAPATI
 
Ambha axi
Ambha axiAmbha axi
Ambha axi
HARINATH REDDY
 
UART
UARTUART
UART
Naveen Kumar
 
Introduction to pic microcontroller
Introduction to pic microcontrollerIntroduction to pic microcontroller
Introduction to pic microcontroller
Siva Kumar
 

Viewers also liked (17)

I2 c bus
I2 c busI2 c bus
I2 c bus
Akhil Srivastava
 
I2c buses
I2c busesI2c buses
I2c buses
Naveen Dubey
 
4 Digit Security Keypad
4 Digit Security Keypad4 Digit Security Keypad
4 Digit Security Keypad
Nestlé
 
137.gsm, fprs ,keypad_based_atm_security_(doc)
137.gsm, fprs ,keypad_based_atm_security_(doc)137.gsm, fprs ,keypad_based_atm_security_(doc)
137.gsm, fprs ,keypad_based_atm_security_(doc)
Karteek Irukulla
 
Designing of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDLDesigning of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDL
Jay Baxi
 
Serial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System ProtocolSerial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System Protocol
Aditya Porwal
 
RTC Interfacing and Programming
RTC Interfacing and ProgrammingRTC Interfacing and Programming
RTC Interfacing and Programming
Devashish Raval
 
Audio devices and applications
Audio devices and applicationsAudio devices and applications
Audio devices and applications
Devashish Raval
 
Fortune Talent Solutions Landing Page
Fortune Talent Solutions Landing PageFortune Talent Solutions Landing Page
Fortune Talent Solutions Landing Page
James Druman
 
the windows opereting system
the windows opereting systemthe windows opereting system
the windows opereting system
Юсуф Сатторов
 
Database assistant performance appraisal
Database assistant performance appraisalDatabase assistant performance appraisal
Database assistant performance appraisal
martinbilly11
 
Catálogo de-productos-fashion-woman-s.a
Catálogo de-productos-fashion-woman-s.aCatálogo de-productos-fashion-woman-s.a
Catálogo de-productos-fashion-woman-s.a
Jezee Llanque
 
Fresher Pitch Deck PUBLIC
Fresher Pitch Deck PUBLICFresher Pitch Deck PUBLIC
Fresher Pitch Deck PUBLIC
Paula Moughton-Weems
 
Farmasötik Yardımcı Maddelerin Toksisitesi
Farmasötik Yardımcı Maddelerin ToksisitesiFarmasötik Yardımcı Maddelerin Toksisitesi
Farmasötik Yardımcı Maddelerin Toksisitesi
Burde Suheyla SUNAR
 
Stewart Kane CV 2016
Stewart Kane CV 2016Stewart Kane CV 2016
Stewart Kane CV 2016
Stewart Kane
 
Bilangan Bulat
Bilangan BulatBilangan Bulat
Bilangan Bulat
Andike96
 
Pratibha_Kakarla
Pratibha_KakarlaPratibha_Kakarla
Pratibha_Kakarla
Pratibha Kakarla
 
4 Digit Security Keypad
4 Digit Security Keypad4 Digit Security Keypad
4 Digit Security Keypad
Nestlé
 
137.gsm, fprs ,keypad_based_atm_security_(doc)
137.gsm, fprs ,keypad_based_atm_security_(doc)137.gsm, fprs ,keypad_based_atm_security_(doc)
137.gsm, fprs ,keypad_based_atm_security_(doc)
Karteek Irukulla
 
Designing of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDLDesigning of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDL
Jay Baxi
 
Serial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System ProtocolSerial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System Protocol
Aditya Porwal
 
RTC Interfacing and Programming
RTC Interfacing and ProgrammingRTC Interfacing and Programming
RTC Interfacing and Programming
Devashish Raval
 
Audio devices and applications
Audio devices and applicationsAudio devices and applications
Audio devices and applications
Devashish Raval
 
Fortune Talent Solutions Landing Page
Fortune Talent Solutions Landing PageFortune Talent Solutions Landing Page
Fortune Talent Solutions Landing Page
James Druman
 
Database assistant performance appraisal
Database assistant performance appraisalDatabase assistant performance appraisal
Database assistant performance appraisal
martinbilly11
 
Catálogo de-productos-fashion-woman-s.a
Catálogo de-productos-fashion-woman-s.aCatálogo de-productos-fashion-woman-s.a
Catálogo de-productos-fashion-woman-s.a
Jezee Llanque
 
Farmasötik Yardımcı Maddelerin Toksisitesi
Farmasötik Yardımcı Maddelerin ToksisitesiFarmasötik Yardımcı Maddelerin Toksisitesi
Farmasötik Yardımcı Maddelerin Toksisitesi
Burde Suheyla SUNAR
 
Stewart Kane CV 2016
Stewart Kane CV 2016Stewart Kane CV 2016
Stewart Kane CV 2016
Stewart Kane
 
Bilangan Bulat
Bilangan BulatBilangan Bulat
Bilangan Bulat
Andike96
 
Ad

Similar to I2C protocol and DS1307 RTC interfacing (20)

COM_BASIC.pptx
COM_BASIC.pptxCOM_BASIC.pptx
COM_BASIC.pptx
BhagvatShukla
 
Implementation of I2C Master Bus Protocol on FPGA
Implementation of I2C Master Bus Protocol on FPGAImplementation of I2C Master Bus Protocol on FPGA
Implementation of I2C Master Bus Protocol on FPGA
IJERA Editor
 
FALLSEM2024-25_BEEE309L_TH_VL2024250101214_2024-10-05_Reference-Material-I.pptx
FALLSEM2024-25_BEEE309L_TH_VL2024250101214_2024-10-05_Reference-Material-I.pptxFALLSEM2024-25_BEEE309L_TH_VL2024250101214_2024-10-05_Reference-Material-I.pptx
FALLSEM2024-25_BEEE309L_TH_VL2024250101214_2024-10-05_Reference-Material-I.pptx
Rahultater4
 
embedded system on board communication.pptx
embedded system on board communication.pptxembedded system on board communication.pptx
embedded system on board communication.pptx
BEVARAVASUDEVAAP1813
 
embedded system on board communication.pptx
embedded system on board communication.pptxembedded system on board communication.pptx
embedded system on board communication.pptx
BEVARAVASUDEVAAP1813
 
embedded system on board communication.pptx
embedded system on board communication.pptxembedded system on board communication.pptx
embedded system on board communication.pptx
BEVARAVASUDEVAAP1813
 
communication interfaces-Embedded real time systems
communication interfaces-Embedded real time systemscommunication interfaces-Embedded real time systems
communication interfaces-Embedded real time systems
Raghunath reddy
 
I2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolI2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication Protocol
Ankur Soni
 
USART - 8251 / usart-8251A Pallav Shukla
USART - 8251 / usart-8251A Pallav ShuklaUSART - 8251 / usart-8251A Pallav Shukla
USART - 8251 / usart-8251A Pallav Shukla
Pallav Shukla
 
I2C PRESENTATION.PPT
I2C PRESENTATION.PPTI2C PRESENTATION.PPT
I2C PRESENTATION.PPT
venkatesh405785
 
Universal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Universal synchronous asynchronous receiver transmitter(usart) and AtoD CoverterUniversal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Universal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Tejas Shetye
 
I2C
I2CI2C
I2C
rchovatiya
 
Dalls02950 1
Dalls02950 1Dalls02950 1
Dalls02950 1
S BW
 
Seminar on serial communication
Seminar on serial communicationSeminar on serial communication
Seminar on serial communication
Samarth Patel
 
Raspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication ProtocolsRaspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication Protocols
Mohamed Abdallah
 
Application Report On Stellaris To Dac5571(I2c)
Application Report On Stellaris To Dac5571(I2c)Application Report On Stellaris To Dac5571(I2c)
Application Report On Stellaris To Dac5571(I2c)
Chiu-Hao Chen (Ted)
 
Lpc2148 i2c
Lpc2148 i2cLpc2148 i2c
Lpc2148 i2c
anishgoel
 
Design of dual master i2 c bus controller
Design of dual master i2 c bus controllerDesign of dual master i2 c bus controller
Design of dual master i2 c bus controller
eSAT Publishing House
 
I2C
I2CI2C
I2C
LITS IT Ltd,LASRC.SPACE,SAWDAGOR BD,FREELANCE BD,iREV,BD LAW ACADEMY,SMART AVI,HEA,HFSAC LTD.
 
Adc and dac
Adc and dacAdc and dac
Adc and dac
nitugatkal
 
Implementation of I2C Master Bus Protocol on FPGA
Implementation of I2C Master Bus Protocol on FPGAImplementation of I2C Master Bus Protocol on FPGA
Implementation of I2C Master Bus Protocol on FPGA
IJERA Editor
 
FALLSEM2024-25_BEEE309L_TH_VL2024250101214_2024-10-05_Reference-Material-I.pptx
FALLSEM2024-25_BEEE309L_TH_VL2024250101214_2024-10-05_Reference-Material-I.pptxFALLSEM2024-25_BEEE309L_TH_VL2024250101214_2024-10-05_Reference-Material-I.pptx
FALLSEM2024-25_BEEE309L_TH_VL2024250101214_2024-10-05_Reference-Material-I.pptx
Rahultater4
 
embedded system on board communication.pptx
embedded system on board communication.pptxembedded system on board communication.pptx
embedded system on board communication.pptx
BEVARAVASUDEVAAP1813
 
embedded system on board communication.pptx
embedded system on board communication.pptxembedded system on board communication.pptx
embedded system on board communication.pptx
BEVARAVASUDEVAAP1813
 
embedded system on board communication.pptx
embedded system on board communication.pptxembedded system on board communication.pptx
embedded system on board communication.pptx
BEVARAVASUDEVAAP1813
 
communication interfaces-Embedded real time systems
communication interfaces-Embedded real time systemscommunication interfaces-Embedded real time systems
communication interfaces-Embedded real time systems
Raghunath reddy
 
I2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolI2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication Protocol
Ankur Soni
 
USART - 8251 / usart-8251A Pallav Shukla
USART - 8251 / usart-8251A Pallav ShuklaUSART - 8251 / usart-8251A Pallav Shukla
USART - 8251 / usart-8251A Pallav Shukla
Pallav Shukla
 
Universal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Universal synchronous asynchronous receiver transmitter(usart) and AtoD CoverterUniversal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Universal synchronous asynchronous receiver transmitter(usart) and AtoD Coverter
Tejas Shetye
 
Dalls02950 1
Dalls02950 1Dalls02950 1
Dalls02950 1
S BW
 
Seminar on serial communication
Seminar on serial communicationSeminar on serial communication
Seminar on serial communication
Samarth Patel
 
Raspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication ProtocolsRaspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication Protocols
Mohamed Abdallah
 
Application Report On Stellaris To Dac5571(I2c)
Application Report On Stellaris To Dac5571(I2c)Application Report On Stellaris To Dac5571(I2c)
Application Report On Stellaris To Dac5571(I2c)
Chiu-Hao Chen (Ted)
 
Design of dual master i2 c bus controller
Design of dual master i2 c bus controllerDesign of dual master i2 c bus controller
Design of dual master i2 c bus controller
eSAT Publishing House
 
Ad

Recently uploaded (20)

ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdfML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
rameshwarchintamani
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
Environment .................................
Environment .................................Environment .................................
Environment .................................
shadyozq9
 
Physical and Physic-Chemical Based Optimization Methods: A Review
Physical and Physic-Chemical Based Optimization Methods: A ReviewPhysical and Physic-Chemical Based Optimization Methods: A Review
Physical and Physic-Chemical Based Optimization Methods: A Review
Journal of Soft Computing in Civil Engineering
 
Artificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptxArtificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptx
rakshanatarajan005
 
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic AlgorithmDesign Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Journal of Soft Computing in Civil Engineering
 
Agents chapter of Artificial intelligence
Agents chapter of Artificial intelligenceAgents chapter of Artificial intelligence
Agents chapter of Artificial intelligence
DebdeepMukherjee9
 
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
Guru Nanak Technical Institutions
 
Optimizing Reinforced Concrete Cantilever Retaining Walls Using Gases Brownia...
Optimizing Reinforced Concrete Cantilever Retaining Walls Using Gases Brownia...Optimizing Reinforced Concrete Cantilever Retaining Walls Using Gases Brownia...
Optimizing Reinforced Concrete Cantilever Retaining Walls Using Gases Brownia...
Journal of Soft Computing in Civil Engineering
 
Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025
Antonin Danalet
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdfDavid Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry
 
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink DisplayHow to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
CircuitDigest
 
Mode-Wise Corridor Level Travel-Time Estimation Using Machine Learning Models
Mode-Wise Corridor Level Travel-Time Estimation Using Machine Learning ModelsMode-Wise Corridor Level Travel-Time Estimation Using Machine Learning Models
Mode-Wise Corridor Level Travel-Time Estimation Using Machine Learning Models
Journal of Soft Computing in Civil Engineering
 
Design of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdfDesign of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdf
Kamel Farid
 
Modeling the Influence of Environmental Factors on Concrete Evaporation Rate
Modeling the Influence of Environmental Factors on Concrete Evaporation RateModeling the Influence of Environmental Factors on Concrete Evaporation Rate
Modeling the Influence of Environmental Factors on Concrete Evaporation Rate
Journal of Soft Computing in Civil Engineering
 
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdfML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
rameshwarchintamani
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
Environment .................................
Environment .................................Environment .................................
Environment .................................
shadyozq9
 
Artificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptxArtificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptx
rakshanatarajan005
 
Agents chapter of Artificial intelligence
Agents chapter of Artificial intelligenceAgents chapter of Artificial intelligence
Agents chapter of Artificial intelligence
DebdeepMukherjee9
 
Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025
Antonin Danalet
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdfDavid Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry
 
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink DisplayHow to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
CircuitDigest
 
Design of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdfDesign of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdf
Kamel Farid
 

I2C protocol and DS1307 RTC interfacing

  • 1. Inter-integrated Circuit (I2 C) Protocol and DS1307 RTC Interfacing Presented by:-Bhargav Kakadiya (140070110006)
  • 2. The I2 C Protocol • Developed by Philips in late 1980s • Version 1.0 published in 1992 – Supports standard (100 Kbps) and fast (400 Kbps) mode • Version 2.0 published in 1998 – High-speed mode (3.4 Mbps) added • Classifies devices into slave and master • Allows multiple masters to be attached to the same bus • The master device uses either a 7-bit or 10-bit address to specify the slave device as its partner of data communication. • Supports bi-directional data transfer • Allows multiple masters (microcontrollers) to share the same peripheral devices
  • 3. I2 C Signal Level • Float high and driven low • Use the SCL signal to carry clock signal to synchronize data transfer • Use the SDA signal to carry data and address • The SDA and SCL pins of I2 C devices (masters and slaves) are open-drain and need external pull up resistors. • The resistors 2.2 KΩ and 1 K Ω are recommended for 100 Kbps and 400 Kbps baud rate.
  • 5. Signal Components • I2 C data transfer consists of 5 signal components: – Start (S) – Stop (P) – Repeated Start (R) – Data – Acknowledge (A)
  • 6. SDA SCL Figure 11.2 I2C Start condition Start Condition • Used to indicate that a device would like to transfer data on the I2 C bus • Represented by the SDA line going low when the clock (SCL) signal is high • Will initialize the I2 C bus
  • 7. SDA SCL Figure 11.3 Stop (P) condition Stop Condition • A condition that a device wants to release the I2 C bus • Is represented by the SDA signal going high when the SCL signal is high • Once the stop condition is complete, both the SCL and SDA signals are high. This is the idle bus.
  • 8. SDA SCL Figure 11.4Restart condition start condtion data transfer restart condition Repeated Start (R) Condition • A Start signal generated without first generating a Stop condition to terminate the communication • Used by the master to communicate with another slave or change data transfer direction without releasing the bus • Also referred to as Restart condition
  • 9. SDA SCL Figure 11.5 I2 Cbus dataelements Note. Data bit is always stable when clock (SCL) is high Data • It represents the transfer of eight bits of information. • Data on the SDA line is considered valid only when the SCL signal is high. • When the SCL signal is low, the data is allowed to change. • The eight-bit data may be a control code, an address, or data.
  • 10. SDA SCL Figure11.6 ACKcondition SDA SCL Figure11.7 NACKcondition Acknowledge (ACK) Condition • Data transfer needs to be acknowledged either positively (A) or negatively (NACK). • A device acknowledges a byte it receives positively by bringing the SDA line low during the ninth clock pulse of SCL. • If the device allows the SDA line to float high, it is transmitting a negative acknowledge (NACK).
  • 11. Synchronization (1 of 2) • All masters generate their clocks on the SCL line to transfer messages on the I2C bus. • A defined clock is needed for the bit-by-bit arbitration procedure to take place. • Most microcontrollers generate the SCL clock by counting down a programmable reload value using the instruction clock signal. • Clock synchronization occurs when multiple masters attempt to drive the I2C bus and before the arbitration scheme can decide which master is the winner. • Clock synchronization is performed using the wired-AND connection of I2C interfaces to the SCL line. • The high-to-low transition on the SCL line causes the devices concerned (masters) to start counting off their low period.
  • 12. Synchronization (2 of 2) • A master device that is counting off their low period will hold the SCL line low until the counter is count down to 0. At this point, the device will release the SCL line to high. • If there are other devices holding the SCL low, then the SCL line will remain low until all master devices have counted down to 0. At this point, the SCL line will go high and all devices will start to count high. • The SCL line will be held low by the device with the longest low period. • By the same reasoning, the high period of the SCL signal is determined by the device with the shortest high period.
  • 13. wait state start counting high period counter reset CLK1 CLK2 SCL Figure 11.8 Clock synchronization during the arbitrationprocedure Handshaking • The clock synchronization mechanism can be used as a handshake in data transfer. • Slave device can hold the SCL line low after completion of one byte transfer (9 bits). • Slave halts the bus until it gets ready for the next operation and then release the SCL line.
  • 14. master 1 loses arbitration Data 1 ≠ SDA SCL Data1 Data2 SDA Figure 11.9 Arbitration procedure of two masters Arbitration • In the event two or more master devices attempt to begin a transfer at the same time, an arbitration scheme is employed to force one or more masters to give up the bus. • The master devices continue to transmit data until one master attempts to send a high while the other transmits a low. • Since the SDA bus has open drain, the master device that attempts to send a high will detect a low. At this point, it will stop driving the bus. • The arbitration process does not slow down the winning master’s transfer and no data gets lost.
  • 15. A6 A5 A4 A3 A2 A1 A0 R/W Figure 11.13a 7-bit I2C address 1 1 1 1 0 A9 A8 R/W A7 A6 A5 A4 A3 A2 A1 A0 Figure 11.13b 10-bit I2C address I2 C Addressing Methods • I2 C protocol allows master devices to use either the 7-bit and 10-bit address to specify the slave device for data communication. • The 7-bit addressing uses the upper 7 bits of the address byte for address and the least significant bit to specify the data transfer direction. The format is shown in Figure 11.13. • The 10-bit addressing uses two bytes to carry the address information. – The bit 0 of the high byte is used to indicate the data transfer direction. – The upper 7 bits have the pattern of 1111 0xx with xx representing the most significant two address bits of the slave. – The second byte carries the lower 8 address bits.
  • 16. S Slave address R/W A Data A Data A/A P data transferred (n bytes + acknowledge) '0' (write) from master to slave from slave to master A = acknowledge (SDA low) A = not acknowledge (SDA high) S = start condition P = stop condition Figure 11.10 A master-transmitter addressing a slave receiver with a 7-bit address. The transfer direction is not changed. Data Transfer Format (7-bit Addressing) (1 of 2) • Master transmitter to slave receiver – shown in Figure 11.10 • Master reads slave immediately after the first byte (address byte) – shown in Figure 11.11 • Combined format. A master may transfer some data to the slave and then generate a restart condition to read data from the slave or send/read data to/from other slave-- shown in Figure 11.12.
  • 17. S Slave address R/W A Data Data P data transferred (n bytes + acknowledge) '1' (read) Figure 11.11 A master reads a slave immediately after the first byte AA S Slave address R/W A Data Data read or write Figure 11.12 Combined format A/A R Slave address R/W A/A P (n bytes + ack.) repeated start read or write A (n bytes + ack.)* direction of transfer may change at this point * not shaded because transfer direction of data and acknowledge bits depends on R/W bits Data Transfer Format (7-bit Addressing) (2 of 2)
  • 18. TWI
  • 19. TWBR TWBR selects the division factor for the bit rate generator. The bit rate generator is a frequency divider which generates the SCL clock frequency in the Master modes. TWBR = Value of the TWI Bit Rate Register TWPS = Value of the prescaler bits in the TWI Status Register
  • 20. TWSR Bits [7:3] – TWS: TWI Status These five bits reflect the status of the TWI logic and the Two-wire Serial Bus. The different status codes are described later in this section. Note that the value read from TWSR contains both the 5-bit status value and the 2-bit prescaler value. The application designer should mask the prescaler bits to zero when checking the Status bits. This makes status checking independent of prescaler setting. This approach is used in this datasheet, unless otherwise noted. Bit 2 – Reserved Bit This bit is reserved and will always read as zero. Bits [1:0] – TWPS: TWI Prescaler Bits These bits can be read and written, and control the bit rate prescaler.
  • 21. TWCR Bit 7 – TWINT: TWI Interrupt Flag This bit is set by hardware when the TWI has finished its current job and expects application software response. If the I-bit in SREG and TWIE in TWCR are set, the MCU will jump to the TWI Interrupt Vector. While the TWINT Flag is set, the SCL low period is stretched. Bit 6 – TWEA: TWI Enable Acknowledge Bit The TWEA bit controls the generation of the acknowledge pulse. If the TWEA bit is written to one, the ACK pulse is generated Bit 5 – TWSTA: TWI START Condition Bit The application writes the TWSTA bit to one when it desires to become a master on the Two wire Serial Bus. The TWI hardware checks if the bus is available, and generates a START condition on the bus if it is free. Bit 4 – TWSTO: TWI STOP Condition Bit Writing the TWSTO bit to one in Master mode will generate a STOP condition on the Two-wire Serial Bus. When the STOP condition is executed on the bus, the TWSTO bit is cleared automatically.
  • 22. Bit 3 – TWWC: TWI Write Collision Flag The TWWC bit is set when attempting to write to the TWI Data Register – TWDR when TWINT is low. This flag is cleared by writing the TWDR Register when TWINT is high. • Bit 2 – TWEN: TWI Enable Bit The TWEN bit enables TWI operation and activates the TWI interface. When TWEN is written to one, the TWI takes control over the I/O pins connected to the SCL and SDA pins, enabling the slew-rate limiters and spike filters. If this bit is written to zero, the TWI is switched off and all TWI transmissions are terminated, regardless of any ongoing operation. • Bit 1 – Reserved Bit This bit is a reserved bit and will always read as zero. • Bit 0 – TWIE: TWI Interrupt Enable When this bit is written to one, and the I-bit in SREG is set, the TWI interrupt request will be activated for as long as the TWINT Flag is high.
  • 23. TWDR These eight bits contain the next data byte to be transmitted, or the latest data byte received on the Two-wire Serial Bus. In Transmit mode, TWDR contains the next byte to be transmitted. In Receive mode, the TWDR contains the last byte received.
  • 24. TWAR These seven bits constitute the slave address of the TWI unit. The TWAR should be loaded with the 7-bit slave address (in the seven most significant bits of TWAR) to which the TWI will respond when programmed as a slave transmitter or receiver. In multimaster systems, TWAR must be set in masters which can be addressed as slaves by other masters.
  • 25. 1X1 2X2 3VBAT 4GND 8 7 6 5 SDA SCL SQWOUT VCC DS1307 Oscillator and divider X1 X2 square wave out SQWOUT power control VCC VBAT GND serial bus interface SCL SDA control logic address register RTC RAM (56x8) Figure 11.27 DS1307 pin assignment and block diagram The Serial Real-Time Clock DS1307 • Uses BCD format to represent the clock and calendar information • Has 56 bytes to store critical information • Clock calendar provides seconds, minutes, hours, day, date, month, and year information • Operates in either the 24-hour or 12-hour format with AM/PM indicator • Has built-in power sense circuit that detects power failure and automatically switches to the battery supply • The SQW output frequency may be 1 Hz, 4 KHz, 8 KHz, and 32 KHz.
  • 26. $00 $07 $08 $3F seconds minutes hours day date month year control RAM 56 x 8 Figure 11.28 DS1307 address map $01 $02 $03 $04 $05 $06 CH 10 seconds seconds 10 minutes0 0 minutes hours12 24 10 HR A/P 10 HR 0 0 0 0 0 day 0 0 0 0 0 10 date 10 month date month year10 year out sqwe0 0 0 0 RS1 RS0 Figure 11.29 Contents of RTC registers Bit 7 Bit 0 - Bit 6 of the hours register selects whether the 12-hour or 24-hour mode is used. - Bit 5 of the hours register selects whether the current time is AM or PM if 12-hour mode is selected. DS1307 Address Map
  • 28. Table11.7 Squarewaveoutputfrequency RS1 RS0 SQWoutputfrequency 0 0 1 1 0 1 0 1 1 Hz 4.096 KHz 8.192 KHz 32.768 KHz DS1307 Control Register • Bit 7 controls the output level of the SQWOUT pin when the square output is disabled. • The SQWE bit enables/disables the SQWOUT pin output. • Bits 1 and 0 select the output frequency of the SQWOUT pin.
  翻译: