[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Fine Tuning code timings

From: David VanHorn
Subject: Re: [avr-gcc-list] Fine Tuning code timings
Date: Fri, 28 Dec 2007 13:50:17 -0500

I've done this in ASM, and as others have suggested, tweak with NOPS
till the bit timing is right.
For inbound data, you shouldn't sample too far from the middle of the bit.
The first low edge you see is the start bit, so delay half a bit time
after that, and sample every bit time after that for the next 8 (7bit)
or 9 (8 bit) data and stop bits.   You may choose to ignore the stop
bit, or require it to be there, or whatever, but this will help you
not to confuse it with the next data byte.

To debug, assuming you have a scope, set an I/O pin high when you're
about to sample, and low after you've grabbed the sample.  When you
scope the data and this pin, you want to see your sample pulses right
in the middle of each bit.  Check the start bit sample first, and
tweak your first half-bit timing to get that right, then adjust your
full bit timer to keep the others centered. If you really want to get
it dead on, pad with NOPs

reply via email to

[Prev in Thread] Current Thread [Next in Thread]