SME
Embedded Systems · Problem type
I²C transaction time
Use this for “How long does a 400 kHz I²C write of 2 data bytes take, address byte included?”
This is an example. Type your own values to start a new problem.
N
=
2
+
9
×
(1
+
k
)
t (μs)
=
N
÷
fSCL (kHz)
Formulas
N
=
2
+
9
×
(1
+
k
)
29 = 2 + 9 × (1 + 2)
t
=
N
fSCL
7.25 ×
10
-5
=
29
400,000
Formulas are worked in Hz, s. The step-by-step shows the conversions.
Assumptions
•
Every byte, the address byte too, is 8 bits and then an ACK bit: 9 clock periods.
•
The first byte is the 7-bit address and the read/write bit; the start and the stop take one bit time each.
•
No clock stretching and no idle time between bytes.
•
A write to a device register sends the register’s address as a data byte first: count it in k.
Step-by-step
WE KNOW
fSCL = 400 kHz, k = 2
FIND
bit times (N), transaction time (t)
Step 1 · Convert to the formula’s units
The formulas don’t work directly in the units you chose, so convert first (to Hz, s).
fSCL = 400 kHz = 400,000 Hz (1 kHz = 1000 Hz)
Step 2 · Find bit times (N)
Use N = 2 + 9 × (1 + k)
The start and stop bits, then 9 clocks for the address byte and for each data byte.
N
=
2
+
9
×
(1
+
2)
N
=
2
+
9
×
3
N
=
2
+
27
N
=
29
Step 3 · Find transaction time (t)
Use t = N ÷ fSCL
Each
bit
time
is
one
SCL
period,
1
fSCL
.
t
=
29
400,000
t
=
7.25 ×
10
-5
s
Step 4 · Convert the answers
Change each answer back to the unit you chose.
t = 7.25 × 10⁻⁵ s = 72.5 μs (1 s = 10⁶ μs)
Check
Put the numbers back in. Both sides should match.
29 = 2 + 9 × (1 + 2) ✓
7.25 ×
10
-5
=
29
400,000
✓
Topic check
See what you know: 5 questions on this topic
New questions each time. Pass to mark it complete.
Related lessons
Serial protocols
Main lesson
Baud-rate register and error
Use this for “A 16 MHz microcontroller sets its UART to 115 200 baud. What goes in UBRR, and how far off is the baud rate?”
SPI throughput
Use this for “An SPI bus clocks at 8 MHz. How many bytes a second can it move, and how long does a 16-bit transfer take?”
UART, SPI or I²C?
Use this for “A bus has two shared wires, pull-up resistors and a 7-bit address for each device. Is it UART, SPI or I²C?”