BookRags.com Literature Guides Literature
Guides
Criticism & Essays Criticism &
Essays
Questions & Answers Questions &
Answers
Lesson Plans Lesson
Plans
My Bibliography Periodic Table U.S. Presidents Shakespeare Sonnet Shake-Up
Research Anything:        
History | Encyclopedias | Films | News | Create a Bibliography | More... Login | Register | Help

Bit-banging

Print-Friendly
About 1 pages (356 words)

Bookmark and Share Questions on this topic? Just ask!

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

<source lang="C"> 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 bit void 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

} </source>

See also

External links

View More Summaries on Bit-banging
 
Ask any question on Bit-banging and get it answered FAST!
Answer questions in BookRags Q&A and earn points toward
discounted or even FREE Study Guides and other BookRags products!
Learn more about BookRags Q&A
Copyrights
Bit-banging from Wíkipedia. ©2006 by Wíkipedia. Licensed under the GNU Free Documentation License. View a list of authors or edit this article.

Article Navigation
Join BookRagslearn moreJoin BookRags




About BookRags | Customer Service | Report an Error | Terms of Use | Privacy Policy