*** Welcome to piglix ***

Bit-banging


Bit banging is a technique for serial communications using software instead of dedicated hardware. Software directly sets and samples the state of pins on the microcontroller, and is responsible for all parameters of the signal: timing, levels, synchronization, etc. In contrast to bit banging, dedicated hardware (such as a modem, UART, or shift register) handles these parameters and provides a (buffered) data interface in other systems, so software is not required to perform signal demodulation. Bit banging can be implemented at very low cost, and is used in, for example, embedded systems.

Although it is often considered to be something of a hack, bit banging does allow the same device to use different protocols with minimal or no hardware changes required. In many cases, bit banging is made possible because more recent hardware operates much more quickly than hardware did when standard communications protocols were created.

Sending a byte on an SPI bus.

The question whether to deploy bit banging or not is a trade-off between load, performance and reliability on the one hand, and the availability of a hardware alternative on the other. The software emulation process consumes more processing power than does supporting dedicated hardware. The microcontroller spends much of its time sending or receiving samples to and from the pins, at the expense of other tasks. The signal produced usually has more jitter or glitches, especially if the processor is also executing other tasks while communicating. However, if the bit-banging software is interrupt-driven by the signal, this may be of minor importance, especially if control signals such as RTS, CTS, or DCD are available. The implementation in software can be a solution when specific hardware support is not available or requires a more expensive microcontroller.


...
Wikipedia

...