317
Software I2C – Interfacing PCF8591 ADC-DAC
Software I2C implementation is a bit complex compared to software SPI. This is because there are
start-stop conditions and acknowledgments that are also needed to be taken care off along with data
transactions. However, it becomes the only option when USI/USCI are absent. Unlike SPI, I2C is slow
and so software implementation doesn’t affect performance significantly.
Shown above is an I2C-based SSD1306 OLED display. This was the display for my weather station. The
weather station was based on a Sparkfun Weather Board. During that project, I was encountering an
issue with the on board SHT15 relative humidity-temperature sensor chip and I could not find out the
issue for quite some time. I thought that the MCU’s TWI module was malfunctioning and so I took the
help of software I2C for rooting out the cause. Cases like these make software I2C-based testing really
useful and interesting.
Shown above is the typical timing diagram for a I2C bus. We can expect the same patterns in both
hardware I2C and software I2C but bus speed may differ. I2C bus speed become critical in some cases.
For example, consider the case of the OLED display above.