0
0
Embedded Cprogramming~10 mins

I2C addressing (7-bit and 10-bit) in Embedded C - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - I2C addressing (7-bit and 10-bit)
Start Condition
Send Address
7-bit Address?
YesSend 7-bit + R/W bit
Wait for ACK
Data Transfer
10-bit Address?
YesSend first 7 bits + 11110 + R/W bit
Wait for ACK
Send last 8 bits
Wait for ACK
Data Transfer
Stop Condition
The I2C master starts communication by sending a start condition, then sends either a 7-bit or 10-bit address with a read/write bit, waits for acknowledgment, and proceeds with data transfer before sending a stop condition.
Execution Sample
Embedded C
uint16_t address = 0x305; // 10-bit address
uint8_t addr_high = (address >> 7) & 0x06 | 0xF0 | (rw & 0x01);
uint8_t addr_low = address & 0xFF;
// Send addr_high, wait ACK
// Send addr_low, wait ACK
// Proceed with data transfer
This code prepares the two parts of a 10-bit I2C address and shows the steps to send them with acknowledgment before data transfer.
Execution Table
StepActionAddress Bits SentR/W BitACK ReceivedNext Step
1Start Condition sent---Send address bits
2Check address length0x305 (10-bit)--Send first address byte
3Send first byte (addr_high)Bits 9-8 + 111100 (write)YesSend second address byte
4Send second byte (addr_low)Bits 7-0-YesData transfer
5Data transfer---Stop condition
6Stop Condition sent---Communication ends
💡 Stop condition sent, communication ends
Variable Tracker
VariableStartAfter Step 3After Step 4Final
address0x3050x3050x3050x305
addr_highN/A0xF40xF40xF4
addr_lowN/AN/A0x050x05
ACKN/AYesYesN/A
Key Moments - 3 Insights
Why do we send two bytes for a 10-bit address but only one for a 7-bit address?
Because 7-bit addresses fit in one byte with the R/W bit, but 10-bit addresses are longer and require sending the first 7 bits with a special prefix, then the remaining 8 bits separately, as shown in steps 3 and 4 of the execution_table.
What does the R/W bit represent and where is it placed?
The R/W bit tells if the master wants to read or write. It is the least significant bit of the first byte sent, combined with the address bits, as shown in step 3.
What happens if the slave does not send an ACK after the address?
The master will stop communication or retry because the slave did not acknowledge, which means no device responded at that address. This is implied after step 3 or 4 if ACK is not received.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the value of addr_high after step 3?
A0xF4
B0x05
C0x305
D0x00
💡 Hint
Check variable_tracker row for addr_high after step 3
At which step does the master send the lower 8 bits of the 10-bit address?
AStep 2
BStep 3
CStep 4
DStep 5
💡 Hint
Look at execution_table action descriptions for step 4
If the slave does not acknowledge at step 3, what should happen next?
AProceed to data transfer
BSend stop condition and end communication
CSend second address byte anyway
DIgnore and continue
💡 Hint
Refer to key_moments explanation about missing ACK after address
Concept Snapshot
I2C addressing uses 7-bit or 10-bit addresses.
7-bit address: sent in one byte + R/W bit.
10-bit address: sent in two parts; first byte has prefix + bits 9-8 + R/W.
Slave must ACK after each address byte.
Communication ends with stop condition.
Full Transcript
This visual execution shows how I2C addressing works for 7-bit and 10-bit addresses. The master starts communication by sending a start condition, then sends the address. For 7-bit addresses, one byte is sent with the read/write bit. For 10-bit addresses, the first byte contains a special prefix plus the two most significant bits of the address and the R/W bit, followed by the second byte with the remaining 8 bits. After each byte, the slave must acknowledge. If acknowledged, data transfer proceeds. Finally, the master sends a stop condition to end communication. Variables like addr_high and addr_low hold parts of the 10-bit address. The execution table traces each step, showing actions, bits sent, and acknowledgments. Key moments clarify common confusions about address length, R/W bit placement, and handling missing acknowledgments. The quiz tests understanding of variable values and protocol flow. This helps beginners see exactly how I2C addressing happens step-by-step.