# I2C Protocol

## Introduction

* Multi master multi slave communication , 128 devices maximum because of the data frame having a fixed bits for addresses
* Maximum of 3mbps , synchronous data transfer protocol
* has start and stop conditions , and a data frame format&#x20;

## configuration / connection

* Multi master multi slave

<figure><img src="/files/MMy14Je7XxhriLmUo29w" alt=""><figcaption><p>I2C connection</p></figcaption></figure>

* SDA - Data line  , SCL - Serial clock
* Open drain / open collector configuration / pull up pull down is required
* In open drain (above image) a pull up resistor is used for idle state and pulled low when required
* uses 4.7kohm resisitor typically

## Details

#### Communication:

* start condition : SDA is pulled low keeping scl (clk) high (idle)&#x20;
* Master sends 7 bit (0-127) slave address first with read/write and waits for ACK/NACK from slave
* slave pulls sda low to indicate ACK&#x20;
* Master sends or recieves  a data frame 8 bit  waits for ack or nack
* slave ACK once recieved&#x20;
* Master stop condition is issued: SDA is high before SCL

<figure><img src="/files/5uFVJAgs7lgZdhN3Z1s7" alt=""><figcaption></figcaption></figure>

### Arbitration / handling multiple slaves from collision

* In Multi master configuration SDA is monitored and if its low then devices wont send data

## Usage and limitations

* As the name suggests its a very low speed communication meant for chip to chip in a pcb
* used in sensors , eeprom etc
* 400kbps in the fast mode&#x20;

## References:

{% embed url="<https://www.ti.com/lit/an/slva704/slva704.pdf?ref_url=https%3A%2F%2Fwww.google.com%2F&ts=1675301205556>" %}
TI i2c explanation
{% endembed %}

{% embed url="<https://www.analog.com/en/technical-articles/i2c-primer-what-is-i2c-part-1.html>" %}

{% embed url="<https://www.circuitbasics.com/basics-of-the-i2c-communication-protocol/>" %}

{% embed url="<https://articles.saleae.com/logic-analyzers/spi-vs-i2c-protocol-differences-and-things-to-consider#i2c>" %}

{% embed url="<https://www.youtube.com/watch?ab_channel=FoolishEngineer&v=UP0aeeuz65U>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://amriths-harijayanthan.gitbook.io/notes/embedded-systems/i2c-protocol.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
