HOME

TheInfoList



OR:

In
computer engineering Computer engineering (CoE or CpE) is a branch of electrical engineering and computer science that integrates several fields of computer science and electronic engineering required to develop computer hardware and software. Computer engineers ...
and
electrical engineering Electrical engineering is an engineering discipline concerned with the study, design, and application of equipment, devices, and systems which use electricity, electronics, and electromagnetism. It emerged as an identifiable occupation in the l ...
, bit banging is a "
term of art Jargon is the specialized terminology associated with a particular field or area of activity. Jargon is normally employed in a particular communicative context and may not be well understood outside that context. The context is usually a particu ...
" for any method of
data transmission Data transmission and data reception or, more broadly, data communication or digital communications is the transfer and reception of data in the form of a digital bitstream or a digitized analog signal transmitted over a point-to-point o ...
that employs software as a substitute for dedicated hardware to generate transmitted signals or process received signals. Software directly sets and samples the states of
GPIO A general-purpose input/output (GPIO) is an uncommitted digital signal pin on an integrated circuit or electronic circuit (e.g. MCUs/ MPUs ) board which may be used as an input or output, or both, and is controllable by software. GPIOs have no ...
s (e.g., pins on a
microcontroller A microcontroller (MCU for ''microcontroller unit'', often also MC, UC, or μC) is a small computer on a single VLSI integrated circuit (IC) chip. A microcontroller contains one or more CPUs (processor cores) along with memory and programmable i ...
), and is responsible for meeting all timing requirements and protocol sequencing of the signals. In contrast to bit banging, dedicated hardware (e.g.,
UART A universal asynchronous receiver-transmitter (UART ) is a computer hardware device for asynchronous serial communication in which the data format and transmission speeds are configurable. It sends data bits one by one, from the least significan ...
, SPI,
I²C I2C (Inter-Integrated Circuit, ), alternatively known as I2C or IIC, is a synchronous, multi-controller/multi-target (master/slave), packet switched, single-ended, serial communication bus invented in 1982 by Philips Semiconductors. It is wide ...
) satisfies these requirements and, if necessary, provides a
data buffer In computer science, a data buffer (or just buffer) is a region of a memory used to temporarily store data while it is being moved from one place to another. Typically, the data is stored in a buffer as it is retrieved from an input device (such a ...
to relax software timing requirements. Bit banging can be implemented at very low cost, and is commonly used in some
embedded systems An embedded system is a computer system—a combination of a computer processor, computer memory, and input/output peripheral devices—that has a dedicated function within a larger mechanical or electronic system. It is ''embedded'' as ...
. Bit banging allows a device to implement different protocols with minimal or no hardware changes. In some cases, bit banging is made feasible by newer, faster processors because more recent hardware operates much more quickly than hardware did when standard communications protocols were created.


C code example

The following
C language C (''pronounced like the letter c'') is a general-purpose computer programming language. It was created in the 1970s by Dennis Ritchie, and remains very widely used and influential. By design, C's features cleanly reflect the capabilities o ...
code example transmits a byte of data on an SPI bus. // transmit byte serially, MSB first void send_8bit_serial_data(unsigned char data)


Considerations

The question whether to deploy bit banging or not is a trade-off between load, performance and reliability on 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 In electronics and telecommunications, jitter is the deviation from true periodicity of a presumably periodic signal, often in relation to a reference clock signal. In clock recovery applications it is called timing jitter. Jitter is a significa ...
or
glitch A glitch is a short-lived fault in a system, such as a transient fault that corrects itself, making it difficult to troubleshoot. The term is particularly common in the computing and electronics industries, in circuit bending, as well as among ...
es, especially if the processor is also executing other tasks while communicating. However, if the bit-banging software is
interrupt In digital computers, an interrupt (sometimes referred to as a trap) is a request for the processor to ''interrupt'' currently executing code (when permitted), so that the event can be processed in a timely manner. If the request is accepted, ...
-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.


See also

*
Bit manipulation Bit manipulation is the act of algorithmically manipulating bits or other pieces of data shorter than a word. Computer programming tasks that require bit manipulation include low-level device control, error detection and correction algorithms, ...
*
Bit stream A bitstream (or bit stream), also known as binary sequence, is a sequence of bits. A bytestream is a sequence of bytes. Typically, each byte is an 8-bit quantity, and so the term octet stream is sometimes used interchangeably. An octet may ...
*
Bit twiddler (disambiguation) In computing, bit twiddler may refer to: * A piece of source code that does ''bit twiddling'', which may mean: ** Doing bit manipulation; ** Interacting with computer hardware, especially when using a bit-banging technique; ** Reading or writing b ...
*
Bit-serial architecture In digital logic applications, bit-serial architectures send data one bit at a time, along a single wire, in contrast to bit-parallel word architectures, in which data values are sent all bits or a word at once along a group of wires. All dig ...
* 1-bit architecture *
Fast loader A fast loader is a software program for a home computer, such as the Commodore 64 or ZX Spectrum, that accelerates the speed of file loading from floppy disk or compact cassette. Floppy disks Fast loaders came about because of a discrep ...
*
Integrated Woz Machine The Integrated Woz Machine (or IWM for short) is a single-chip version of the floppy disk controller for the Apple II. It was also employed in Macintosh computers. History When developing a floppy drive for the Apple II, Apple Inc. co-founde ...
(IWM) *
FTDI Future Technology Devices International Limited, commonly known by its acronym FTDI, is a Scottish privately held semiconductor device company, specialising in Universal Serial Bus (USB) technology. It develops, manufactures, and supports dev ...
, a series of USB to serial converter chips also supporting a bit bang mode *
2MGUI 2M is a DOS program by the Spanish programmer Ciriaco García de Celis. It enables higher than normal capacity formatting of floppy disks. It saw active development from 1993 to 1995. The last version, v3.0, was released on 6 March 1995. It was ...
(a DOS driver by Ciriaco García de Celis utilizing bit-banging to support non-standard ultra-high capacity floppy disk formats "bypassing" the normal floppy controller logic, a similar program for Amiga floppies is Vincent Joguin's Disk2FDI) *
Virtual machine In computing, a virtual machine (VM) is the virtualization/emulation of a computer system. Virtual machines are based on computer architectures and provide functionality of a physical computer. Their implementations may involve specialized hardw ...
(VM) (implementing virtual device drivers emulating actual hardware controllers sometimes involves utilizing programming techniques similar to bit banging) *
Software-defined radio Software-defined radio (SDR) is a radio communication system where components that have been traditionally implemented in analog hardware (e.g. mixers, filters, amplifiers, modulators/demodulators, detectors, etc.) are instead implemented by me ...
(SDR) *
Polling (computer science) Polling, or polled operation, in computer science, refers to actively sampling the status of an external device by a client program as a synchronous activity. Polling is most often used in terms of input/output (), and is also referred to as po ...


References

{{reflist, refs= {{cite book , title=Programming and customizing PICmicro microcontrollers , edition=2nd , author-first=Michael , author-last=Predko , publisher=
McGraw-Hill Professional McGraw Hill is an American educational publishing company and one of the "big three" educational publishers that publishes educational content, software, and services for pre-K through postgraduate education. The company also publishes referenc ...
, date=2000 , isbn=978-0-07-136172-9 , page
10
��12 , url=https://archive.org/details/programmingcusto00pred_0, url-access=registration


External links

;Asynchronous serial (RS-232)





;I²C bus

;SPI bus
Efficient bit-banged SPI for 8051 microcontroller
Data transmission Signal processing Digital circuits Embedded systems