Bit-banging

Bit-banging

Bit-banging is a technique for serial communications to use software instead of dedicated hardware such as a UART or shift register. A software routine handles the UART transmit function by alternating a pin on the microcontroller by given time intervals. A receiver function is implemented by sampling a pin on the microcontroller by a given time interval. The technique can be applied in very low cost embedded systems.

With a few extra components, video signals can be output from digital pins.(See TV Typewriter).

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.

There are some problems with bit-banging. More processing power is consumed in the software emulation process than in supporting dedicated hardware. The microcontroller is busy most of the time looking at samples or sending a sample to the pin, instead of performing other tasks. The signal produced normally has more jitter or glitches, if the processor is also executing other tasks while communicating. However, if the bit-banging software is hardware interrupt-driven by the signal, this may be of minor importance.

C code example

const unsigned char bitMask8 [] = { 0x80, // binary 10000000 0x40, // binary 01000000 0x20, // binary 00100000 0x10, // binary 00010000 0x08, // binary 00001000 0x04, // binary 00000100 0x02, // binary 00000010 0x01 // binary 00000001};

// This will send data in bit7~0, updating the clock each bitvoid send_8bit_serial_data(unsigned char data){ unsigned char x;

output_high(SD_CS); // lets select the device

// Loop through all the bits, 7...0 for(x = 0; x < 8; x++) { if(data & bitMask8 [x] ) { output_high(SD_DI); // we have a bit, make high } else { output_low(SD_DI); // no bit, make low }

output_low(SD_CLK); // update clock output_high(SD_CLK); // update clock }

output_low(SD_CS); // lets DE-select the device}

ee also

*Software-defined radio

External links

* [http://stud3.tuwien.ac.at/~e9725348/Theses/ Universal Asynchronous Receiver/Transmitters: A Software Implementation Approach] , a diploma thesis by Herbert Valerio Riedel, Vienna University of Technology
* [http://dt.prohosting.com/pic/pong.html VCR Pong] , an example of bit-banged NTSC video
* [http://www.brouhaha.com/~eric/pic/bitbanging.html Notes on Bit-Banging Async Serial]
* [http://www.dnatechindia.com/index.php/Tutorials/8051-Tutorial/Bit-Banging.html Bit Banging Algorithm]


Wikimedia Foundation. 2010.

Игры ⚽ Нужна курсовая?

Look at other dictionaries:

  • Bit-banging — технология организации последовательного соединения с использованием программной эмуляции вместо специализированного устройства. Программа непосредственно устанавливает состояние выводов на микроконтроллере, таким образом полностью обеспечивая… …   Википедия

  • Bit-Banging — Unter Bit Banging versteht man eine Technik, die mittels Software und I/O Leitungen eine Hardware Schnittstelle emuliert, die gewöhnlich mit einem spezifischen Peripherie Baustein realisiert wird. Auf einem PC können sowohl der Seriell Port als… …   Deutsch Wikipedia

  • Bit twiddler — 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… …   Wikipedia

  • PICAXE — is the name of a UK sourced microcontroller system based on a range of Microchip PICs. There are 13 PICAXE variants of differing pin counts from 8 to 40 pins. Initially marketed for use in education and by electronics hobbyists, they are also… …   Wikipedia

  • Bitbang — Unter Bit Banging versteht man eine Technik, die eine Hardware Schnittstelle mittels Software und I/O Leitungen emuliert, die gewöhnlich mit einem spezifischen Peripherie Baustein realisiert wird. Auf dem PC können sowohl der Seriell Port als… …   Deutsch Wikipedia

  • Bitbanging — Unter Bit Banging versteht man eine Technik, die eine Hardware Schnittstelle mittels Software und I/O Leitungen emuliert, die gewöhnlich mit einem spezifischen Peripherie Baustein realisiert wird. Auf dem PC können sowohl der Seriell Port als… …   Deutsch Wikipedia

  • Ben NanoNote — A Ben NanoNote held on the palm of a hand Manufacturer Qi hardware, Sharism At Work Ltd Operating system Custom edition of OpenWrt …   Wikipedia

  • Brotkasten (c64) — Der C64 im „Brotkasten“ Gehäuse Der Commodore 64 (kurz: C64, umgangssprachlich auch 64er) ist ein 8 Bit Heimcomputer mit 64 KByte Arbeitsspeicher. Seit seiner Vorstellung im Januar 1982 auf der Winter Consumer Electronics Show war der von… …   Deutsch Wikipedia

  • C-64 — Der C64 im „Brotkasten“ Gehäuse Der Commodore 64 (kurz: C64, umgangssprachlich auch 64er) ist ein 8 Bit Heimcomputer mit 64 KByte Arbeitsspeicher. Seit seiner Vorstellung im Januar 1982 auf der Winter Consumer Electronics Show war der von… …   Deutsch Wikipedia

  • C64 — Der C64 im „Brotkasten“ Gehäuse Der Commodore 64 (kurz: C64, umgangssprachlich auch 64er) ist ein 8 Bit Heimcomputer mit 64 KByte Arbeitsspeicher. Seit seiner Vorstellung im Januar 1982 auf der Winter Consumer Electronics Show war der von… …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”