Autobaud detection normally works by timing the actual bits received, not using the UART, then programming the UART for the correct baud rate. Bob Ammerman RAm Systems ----- Original Message ----- From: "Andreas Nyholm" To: Sent: Thursday, May 30, 2002 5:10 AM Subject: [PIC] Automatic baud detection > Hi, > Have anyone tried make automatic baud detection for RS232 on the PIC? > Let's say that the PC send AT to the serial port and if the PIC receive it > correctly it's using the right baud rate. > Here is a piece of the code I have been trying to use: > RadioRSSetup ; Boot Baud Rate = X, No Parity, 1 Stop Bit > Bank0 ;Change to bank0 > bsf PORTB,RTS_OUTPUT ;set RTS off before setting as output > Bank1 > bcf TRISB,RTS_OUTPUT ;enable RTS pin as output > movlw BAUD_C38400 ; 38400 baud so far > movwf SPBRG > movlw b'00100100' ; brgh = high > movwf TXSTA ; enable Async Transmission, set brgh > Bank0 > movlw b'10010000' ; enable Async Reception > movwf RCSTA > call Receive > xorlw 'A' > btfss STATUS,Z > goto B19 ; test at 19200 baud > return > > Receive gets a byte from RCREG. I have been trying to use a loop until I > get a character and a routine that just move data from RCREG and continue. > This far it just checks if I got an 'A'. > > The result I get is that mostly I get it to work with 38400 and 19200 baud > (I do have tried that it use the right baud rate) But with 9600 it doesn't > work at all. > I hope someone have comments about my code to say if this is a good > solution. Otherwise I'll just keep on trying and hope I'll get it to work > :) > > Thanks for your answers! > Andreas > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > > -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body