On 12 Jun 2008 at 10:27, Bob Blick wrote: > = > On Thu, 12 Jun 2008 13:38:09 -0300, "Alexandre Guimar=E3es" > said: > = > > Can you explain better how to do it with 2x sampling ? I have always > > used 3 times and it works because it is able to detect the start bit in > > at > > least in the first third part of the start bit. How can you detect the > > start > > bit and take the samples consistently with 2x the baud rate ?? > = > Hi Alexandre, > = > You caused me to look :) I used 4x sampling and got 9600 baud with 14MHz > xtal. That is the method I show in the LCDterm: > = > http://bobblick.com/techref/projects/lcdterm/lcdterm.html > = > When I have done 2x sampling I could do 9600 baud with slower xtal but > it is definitely less robust. The method was to set up a timer interrupt > 19200 per second. Look for a start bit at the beginning of the interrupt > routine, process incoming bits every 2 interrupts after that but process > the incoming bits at the end of the timer interrupt, after the send > routine and buffer routines. So there is less consistency in where the > bit is captured but there is enough of a delay that if the start bit is > detected at the very beginning you still get some margin. > = > Cheerful regards, > = > Bob > = I have done soft-uarts using just 1x sampling. Detected the start-bit with an edge interrupt, set the next timer = interrupt for 1.5 bit-time and the other interrupts for one bit-time. Never had a single problem but never used on noisy signals. Mark Jordan -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist