Hello again! On Thu, 30 May 2002, Lee Jones wrote: > > >> If you can arrange to measure the bit widths on the pin then > >> you will probably arrive at the required baud rate a lot quicker. > > Normally, auto-baud is done by measuring the width of a single > bit. That bit is normally the start bit of the frame. To ensure > that a single bit is measured, the first data bit (low order bit) > has to be a 1. This criteriun is met by the sending using an > ASCII character of carriage return, '1', '3', '5', '7', '9', 'A', > 'a', 'C', 'c', 'E', 'e', etc. All that matters is that the low > order bit of the character is a 1. > > Wire the receive data line to a pin. Watch the pin for voltage > transition (direction depends on your hardware). Start a timer. > When you see the next transtition, stop timer. Invert bit time > (via table or If-Else tree) into baud rate. Program hardware > UART. Then check next character for validity & framing. If it > doesn't "look right", start over. > carriage return, ASCII '1', ASCII 'A', ASCII 'a', > I was trying this quite sucessfully at first. I was measuring the width of one bit with every baudrate I need. Everything was working properly and I was happy, but when I put everything together it wasn't working that good anymore. One problem I have is that when I turn on the PIC before I send the character I get one time, and when I send the character and then turn on the PIC I get another.. So, it looks like I'm measuring an extra bit when I send the character before turning on my PIC. (the measuring time was ~2*the first time.) Any ideas what this is? It must be something before the start bit or am I wrong? I have been taking some days off with this autobaud, but yesterday I started to try my first idea, to xorlw the received character with 'A' and try again with next baudrate if it's wrong. This I got now is improved from the first one, I've got frame error checking and so one... I also forgot to flush the receiver buffer in the first version, but now I have tried with that too. But I'm not really sure how and when to do that so I've tried many different ways. But since I'm still writing I didn't get it to work... I start with 38400 baud and goes down to 19200 and then to 9600 and last 4800 baud. My version works with 38400 without problems, and with 19200 when I press A two times, but when I'm going down to 9600 I don't get it to work anymore. I have BRGH=1 at 9600 and higher and BRGH=0 at 4800. I hope someone can give me more ideas what to do. /Andreas > Someone else replied: > > > The character for [a US-ASCII] 'A' will have a picture like > > this on an oscilloscope [...]. A capital S is a start bit, and > > a lower case S is a stop bit. > > > > _____ _____ __________ > > waveform | S | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | s | S | > > ----------- -------------------------- ------ > > This diagram shows the bits being sent most significant bit first. > It is reversed. > > This is incorrect. Serial data is transmitted low order bit first. > It has to be since the number of bits per byte may vary. Common > sizes have been 5 bits/byte up to 9 bits per byte. > -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads