CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Re: Autobauding

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
marcus
Guest







Autobauding
PostPosted: Tue Jul 16, 2002 7:09 am     Reply with quote

Hello,

i want to implement an autobauding (detect the baudrate automaticly) on an PIC 18f452. How can i do this just with
the UART ? I cant modify the PCB.
I know that the first chars are "AT<CR>".
(Do you know what i try to implement ?)
Thanks.
___________________________
This message was ported from CCS's old forum
Original Post ID: 5555
Sherpa Doug
Guest







Re: Autobauding
PostPosted: Tue Jul 16, 2002 8:23 am     Reply with quote

:=
:=Hello,
:=
:=i want to implement an autobauding (detect the baudrate automaticly) on an PIC 18f452. How can i do this just with
:=the UART ? I cant modify the PCB.
:=I know that the first chars are "AT<CR>".
:=(Do you know what i try to implement ?)
:=Thanks.

I think you have to read the serial line as a direct input bit, bypassing the UART. Trigger on the Start bit, read the length of the Start bit plus any adjacent bits in "A", calculate the baud rate.
It ain't nice but it is the only way I know. I prefer to avoid autobauding entirely.
___________________________
This message was ported from CCS's old forum
Original Post ID: 5558
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: Autobauding
PostPosted: Tue Jul 16, 2002 1:46 pm     Reply with quote

:=
:=Hello,
:=
:=i want to implement an autobauding (detect the baudrate automaticly) on an PIC 18f452. How can i do this just with
:=the UART ? I cant modify the PCB.
:=I know that the first chars are "AT<CR>".
:=(Do you know what i try to implement ?)
:=Thanks.

If you have enough incoming data you can detect framin errors in bytes and switch baud rate untill you have recieved data with a low ratio of framing errors.

if(bit_test(RS232_ERRORS,2)) // Check for framing errors
{RS232_ERRORS=0;
++FramingErrorsCount; // increment count of errors
if(bit_test(FramingErrorsCount,5)) // if 32 errors
DynamicBaud();} // change baud

I clear error count on recieving a good packet.
___________________________
This message was ported from CCS's old forum
Original Post ID: 5588
Dan Mullin
Guest







Re: Autobauding-Neutone has it right
PostPosted: Thu Jul 18, 2002 3:46 pm     Reply with quote

:=
:=Hello,
:=
:=i want to implement an autobauding (detect the baudrate automaticly) on an PIC 18f452. How can i do this just with
:=the UART ? I cant modify the PCB.
:=I know that the first chars are "AT<CR>".
:=(Do you know what i try to implement ?)
:=Thanks.

Neutone has it right. However, I would skip running interrupts until the baud is determined. Once you find the correct rate set up your interrupts.

//Automatically adjusts baud rate to incoming serial stream.
void Autobaud() {
int fail_cnt, dummy, index, out_loop;
for( out_loop = 0; out_loop < 5; out_loop++ ) {
switch( out_loop ) {
case 0 : set_uart_speed( 57600 );
break;
case 1 : set_uart_speed( 38400 );
break;
case 2 : set_uart_speed( 28800 );
break;
case 3 : set_uart_speed( 19200 );
break;
case 4 : set_uart_speed( 14400 );
break;
}
fail_cnt = 0;
for( index = 0; index < 25; index++ ) {
dummy = getc(); // wait for a byte from serial
if( bit_test(RS232_ERRORS, 2)) // if a framing error then
fail_cnt++; // increment count
}
if( fail_cnt < 6 ) // if less than 20\% FE
return; // found baud so exit
}
set_uart_speed( 9600 ); // else default to 9600
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 5678
Acetoel
Guest







Re: Autobauding
PostPosted: Thu Mar 13, 2003 3:56 am     Reply with quote

Hi Sherpa Doug,
I need to do autobouding. I rcv 0x55 from a device, but I don't know the speed the device could send that 0x55. I have 35ms after the next byte. How can I measure the Start Bit using the HUART? Do you have a piece of code for that?

Thanks
Ezequiel

:=:=
:=:=Hello,
:=:=
:=:=i want to implement an autobauding (detect the baudrate automaticly) on an PIC 18f452. How can i do this just with
:=:=the UART ? I cant modify the PCB.
:=:=I know that the first chars are "AT<CR>".
:=:=(Do you know what i try to implement ?)
:=:=Thanks.
:=
:=I think you have to read the serial line as a direct input bit, bypassing the UART. Trigger on the Start bit, read the length of the Start bit plus any adjacent bits in "A", calculate the baud rate.
:=It ain't nice but it is the only way I know. I prefer to avoid autobauding entirely.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12608
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group