General I2C protocol

From BitWizard WIKI
Jump to: navigation, search

BitWizard expansion boards communicate using an I2C protocol.

I2C is a standard protocol, sometimes called "TW" or "TWI" by other manufacturers. Each I2C slave has its own I2C address. This allows us to daisy chain a large number of boards. The BitWizard I2C boards can be told to use a different I2C address so that you can resolve conflicts if you would otherwise have several devices at one address.


The slaves use an ATTINY44 processor. These have a hardware universal serial interface (USI) module that can be configured as "I2C slave". Many things however have to be processed in software. This means that some time is required between each byte. The hardware of the ATTINY44 will pull the SCL line low while the processing is not finished. If you use a software I2C master, doublecheck that your I2C master supports this feature.

The I2C protocol is specified at 100kHz and 400kHz bit rate. If you lower the pullup resistors a bit and have a short bus, the hardware will probably be able to handle bit rates up to 2MHz. This is not recommended. Use the standard 400kHz.


To send a sequence of bytes to the slave I2C device, the master starts by creating a START condition: the SDA line goes low while SCL is held high. All slaves are now primed to receive an "address" byte. Next the master sends the address byte.

After this the protocol in theory depends on which slave you are talking to. In practice so far it is convenient to make the slaves talk a similar protocol: the next byte specifies a "register" or "port" address. After this you can send data to that port or register.

If the data can be considered a "data stream" like with the I2C_LCD board, you can call it a "port". If there is just a single value, it is more common to call it a register.