
This helps ensure the microcontroller doesn’t waste too much processing power. Receiving data tends to be a little bit more complex, usually an interrupt is used to determine when data is available on the receiver pin.
Check if all data bits have been sent. Wait for duration to correspond with the baud rate of receiver again. Wait for timing to correspond with the baud rate of receiver. To send data for instance the pseudo-code below is used While the code to implement bit banging may differ across diverse microcontrollers and may also vary for different serial protocols, but the procedure/algorithm for implementing bit banging is the same across all platforms. A microcontroller which is previously enabled for UART communication only, can be equipped to communicate using SPI and 12C via bit banging.Īlgorithm for Serial Communication via Bit Banging It thus provides a cheap way of enabling the same device to communicate using several protocols. The software sets all the parameter needed to achieve this communication including synchronization, timing, levels etc., which are usually decided by dedicated hardware when bit banging is not used.īit-Banging is usually used in situations where a microcontroller with the required interface is not available or when switching to a microcontroller with the required interface might be too expensive. To receive data, the technique involves sampling the state of the Rx pin after certain intervals which is determined by the communication baud rate. To transmit data, the technique involves the use of software to encode the data into signals and pulses which are used to manipulate the state of an I/O pin of a microcontroller which serves as the Tx pin to send data to the target device. What is Bit Banging?īit banging is a technique for serial communication in which the whole communication process is handled via software instead of dedicated hardware. In situations like these the techniques like Bit Banging come in to play.
The existence of some of these interfaces like SPI and I2C on microcontroller invariably increases the cost of such microcontrollers, and depending on the BOM budget it may make a desired microcontroller not affordable.
The designer ensures that the microcontroller being selected has all the interfaces required to communicate with all the other components to be used for the product. Communication Interfaces are one of the factors that are considered when selecting a microcontroller to be used for a project.