Short notes

I2C Short Notes

Connecting an MPU-6050 IMU and a 24C02 EEPROM to the same two wires — SDA on PB7 and SCL on PB6 — is exactly what I2C was designed for. Both devices share the bus simultaneously, responding only when their 7-bit address appears after a START condition. The 24C02 listens at address 0x50, while the MPU-6050 sits at 0xD0 (write) or 0xD1 (read) depending on its AD0 pin. External 4.7 kΩ pull-up resistors to 3.3 V on both SDA and SCL lines are not optional — without them, the open-drain bus never returns high.

ECE, EI

How it works

A transaction begins when the master pulls SDA low while SCL is high — that is the START condition. The master then clocks out a 7-bit address plus a read/write bit; the addressed slave pulls SDA low for one clock cycle to ACK. In write mode, data bytes follow with ACK after each one; in read mode, the master releases SDA and the slave drives it. Clock stretching lets a slow slave hold SCL low to pause the master. Standard mode runs at 100 kHz; fast mode at 400 kHz; fast-mode plus reaches 1 MHz using lower pull-up resistor values around 1 kΩ.

Key points to remember

I2C supports up to 127 devices on a single bus using 7-bit addressing (10-bit addressing extends this to 1023). Pull-up resistor value directly affects rise time — 4.7 kΩ is standard for 100 kHz, while 400 kHz mode typically needs 2.2 kΩ or lower. A missing ACK causes the master to abort the transaction and set the AF (Acknowledge Failure) flag in the I2C status register. Repeated START allows a master to change direction from write to read without releasing the bus, essential for register-read operations on devices like the BMP280 sensor.

Exam tip

The examiner always asks you to draw the complete I2C waveform for writing one byte to a slave, including START, address, R/W bit, ACK, data byte, ACK, and STOP — practice drawing this from memory.

More Embedded Systems notes