Soft interfaces vs Hardware

“When you go hard your nays become yays.”

Nicki Minaj

In many cases interfacing embedded devices using interfaces like I2C and SPI, there are hardware peripherals in the System-on-a-chip (SoC) which are connected to some of the IO pins, either directly or via an IO Multiplexer (IOMUX).

These hardware blocks are useful because they support features like interrupts, DMA, fast clock speeds, multiple clocks sources, often programmable wire formats (e.g. SPI Mode 1,2,3) etc. The IOMUX if available allows flexible connection of the interface to the GPIO pins, allowing the developer to be more flexible on the pins they wire the physical device to.

Sometimes, however, you just want a convenient low speed interface to a small peripheral, or you can’t use the hardware block for some reason such as it already being in use, or the pins not being exposed. In these case an alternative exists called “soft I2c” or bitbanging. This term refers to using software to generate the timing signals and update the GPIO pins between level 0 and 1 directly. Bitbanging is often used for the Dallas Semiconductor 1-wire bus, which is relevant for many temperature sensors.

Bitbanging is also supported by many embedded system Board Support Packages (BSP) and is a viable alternative if you can’t use hardware interfaces. Remember however that to go fast, you need to go hard.

For more details see this excellent article http://www.bitbanging.space/posts/bitbang-i2c