Featured
- Get link
- X
- Other Apps
Introduction to Bit Walloping SPI communication via Bit Banging
Introduction
to Bit Walloping SPI communication via Bit Banging
Communication Interfaces are one of the elements which can
be considered while selecting a microcontroller to be used for a undertaking.
The designer guarantees that the microcontroller being selected has all of the
interfaces required to speak with all the other components to be used for the
product. The existence of a number of those interfaces like SPI and I2C on
microcontroller continuously will increase the cost of such microcontrollers,
and depending at the BOM budget it may make a favored microcontroller now not
less expensive. In situations like those the strategies like Bit Banging are
available in to play.
What is Bit Banging?
Bit banging is a method for serial conversation in which the
entire communication procedure is treated via software in preference to
committed hardware. To transmit information, the method includes the use of
software to encode the information into signals and pulses that are used to
govern the nation of an I/O pin of a microcontroller which serves as the Tx pin
to send information to the goal tool. To acquire information, the method
involves sampling the country of the Rx pin after positive periods that is
decided with the aid of the communication baud price. The software units all
the parameter needed to acquire this conversation together with
synchronization, timing, tiers and so on., which can be normally determined by
means of dedicated hardware while bit banging isn't used.
When to apply Bit Banging
Bit-Banging is typically utilized in situations in which a
microcontroller with the specified interface isn't available or whilst
switching to a microcontroller with the desired interface is probably too
costly. It thus presents a reasonably-priced way of enabling the identical
device to talk the usage of several protocols. A microcontroller that is
previously enabled for UART verbal exchange best, may be equipped to speak the
usage of SPI and 12C thru bit banging.
Algorithm for Serial Communication thru Bit Banging
While the code to put in force bit banging might also vary throughout
numerous microcontrollers and may additionally vary for distinctive serial
protocols, but the method/algorithm for implementing bit banging is the equal
throughout all systems.
To ship statistics for example the pseudo-code underneath is
rummage-sale;
Start
Send jump bit
Wait for timing to resemble with the baud charge of receiver
Send statistics bit
Wait for period to correspond with the baud rate of receiver
once more
Check if all records bits were despatched. If no, go to 4.
If sure, goto 7
Send stop bit
Stop
Receiving data tends to be a bit bit greater complex,
generally an interrupt is used to decide whilst information is available at the
receiver pin. This enables make certain the microcontroller doesn’t waste too
much processing energy. Although certain applications use any of the
microcontrollers I/O pins but the probabilities of noise and mistakes, if no
longer probably dealt with, is better. The algorithm to obtain information the
usage of interrupts is defined underneath.
Start
Enable interrupt on Rx pin
When interrupt is precipitated, achieve start bit
Wait for timing in keeping with the baud rate
Read the Rx pin
Repeat from four till all facts has been received
Wait for timing according to the baud price
Check for forestall bit
Stop
Bit Banging over SPI
As mentioned above, bit thumping for different protocols
paintings otherwise and it’s accordingly crucial to read approximately each
protocol, to understand facts framing and clocking earlier than trying to
implement. Taking the SPI mode 1 for example, the bottom fee of the clock is
usually zero and information is usually despatched or received at the rising
fringe of the clock. The judgement drawing for the SPI Mode 1 conversation
protocol is shown below.
- Get link
- X
- Other Apps
Comments
Post a Comment