Embedded Systems Interview Prep: Communication Protocols Edition

1.      Explain the I2C protocol?

I²C (Inter-Integrated Circuit) is a synchronous, multi-master, multi-slave, serial communication protocol using just two lines: SDA (data) and SCL (clock). It allows multiple slave devices to communicate with one or more master devices, commonly used for connecting low-speed peripherals like sensors and RTCs.

2.      Explain the UART protocol frame?

UART (Universal Asynchronous Receiver/Transmitter) transmits data asynchronously, typically in this frame format:  Start bitData bits (5–9)Optional Parity bitStop bit(s)

There's no shared clock; both devices must agree on baud rate.

3.      Explain I2C data frame.

Each I²C transaction includes a Start condition, 7-bit address + R/W bit, ACK/NACK, data bytes, and a Stop condition. The master initiates communication and the slave respond. Data is transferred 8 bits at a time, MSB first.

4.      Differences between I2C and UART:

Article content

5.      Explain the SPI protocol

SPI (Serial Peripheral Interface) is a full-duplex, synchronous protocol using 4 lines: MISO, MOSI, SCLK, and SS (slave select). It’s faster than I2C, supports multiple slaves via chip select lines, and is commonly used in high-speed applications like Flash memory.

6.      Describe I2C arbitration.

When multiple masters try to control the bus simultaneously, arbitration ensures only one takes control. It happens bit-by-bit during transmission. The master that sends a high while another sends a low loses arbitration and backs off, allowing collision-free operation.

7.      What is I2C clock stretching?

Clock stretching allows a slave device to hold the SCL line low if it’s not ready to send or receive data, effectively pausing the master. Once ready, the slave releases SCL and communication resumes—it's a form of hardware-level handshaking.

8.      What will happen if two slaves have the same address in I2C?

I²C doesn’t support slaves with the same address. If two slaves share an address, data corruption or unpredictable behavior occurs since both may try to respond simultaneously. It's a design-time error that must be avoided.

9.      How many slaves are possible in I2C and SPI?

·         I2C can theoretically have 127 salves with 7-bit addressing (or 1023 with 10-bit but limited by unique addresses and bus capacitance.

·         SPI can theoretically have Unlimited Each slave requires a dedicated Slave Select (SS) line from the master but practically limited by available GPIO pins.

·         I2C uses addressing, so you can connect many devices as long as their addresses don’t collide.

·         SPI doesn’t use addressing; each slave must have a separate chip-select pin, making large systems cumbersome without multiplexing or daisy-chaining (for some specialized devices)

10. What happens when two I2C masters try to access the same slave simultaneously (one for read, one for write)?

This scenario is handled by I²C arbitration:

- Both masters begin transmitting and monitor the SDA line in real time.

- Bit-by-bit, if a master tries to send a high (1) but sees a low (0) on SDA, it loses arbitration and stops transmitting.

- The master that maintains control continues the transaction—**regardless of whether it's a read or write.

- The bus ensures no corruption, thanks to this hardware-level arbitration mechanism.

So, in your case:

- The two masters will start, but only one (read or write) will win arbitration.

- The losing master backs off and can retry after the current transaction ends.

This system ensures orderly communication, even in multi-master setups!

11. Which protocol to be selected? Protocol Selection Based on Scenarios

o   I2C: Best for low-speed sensor networks, RTCs, EEPROMs — where addressability and fewer wires are preferred.

o   SPI: Go-to for high-speed peripherals like displays, ADCs, Flash memory — where speed trumps wire count.

o   UART: Ideal for serial communication between two devices, especially over longer distances

Great list of protocol questions - super helpful for interview prep! 

Like
Reply

Thanks for sharing, Thanooja

To view or add a comment, sign in

Others also viewed

Explore content categories