Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: question about serial port bit banging

2005-12-27 by Don Kinzer

--- In AVR-Chat@yahoogroups.com, James Washer <washer@t...> wrote:
> Is this correct?

Yes.

As you may know, the trick to bit banging a serial input is to arrange 
to sample the input line consistently somewhere near the middle of the 
bit window.  Generally, this means that you need to sample the input 
line at some multiple of the bit frequency (probably 4x is the lowest 
practical multiple, 8x or higher is even better if you can afford the 
overhead) and then arrange to sample the input line at multiples of 
the bit time after a start bit has been detected.  This process is 
complicated by the fact that the transmitter's clock can have 
virtually any phase relationship to the receiver's clock so you have 
to design your software to accommodate the worst-case clock skew.  
Moreover, the transmitter's clock and the receiver's clock can vary 
from the ideal frequency in opposite directions and the resultant 
error is cumulative over the 9 to 11 bits of the character being 
received.

Compared to reception, bit bang transmission is a cinch.

I implemented a 4-channel bit bang full duplex UART in assembly 
language for the ZX microcontrollers; they are based on a mega32 
running at 14.7456MHz.

Don
ZBasic Microcontrollers
http://www.zbasic.net

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.