|
|
View previous topic :: View next topic |
Author |
Message |
Acetoel Guest
|
I Think I solve the Autobaud rate rutine |
Posted: Sat Mar 15, 2003 11:18 am |
|
|
Well, justo to remember I'm using a 16F76 at 20MHz, using the Hardware UART and I receive 0x55 from a terminal, which speed of comm. I don't know.
So I use the pin as a normal input, and wait the start bit, measure it, and two more bits. then take and average and load the baudrate directly to the Serial Port Register.
Here I the rutine
Unsigned Int16 Count1,Count2,Count3,Speed
While(RXPin){}
While(!RXpin) {
delay_us(1); //Think that some NOPs will be better
count1++;
}
While(RXpin){
delay_us(1);
count2++;
}
While(!RXpin){
delay_us(1);
count3++;
}
Speed = (Count1 + count2 + Count3) / 3
//Well, and then I load the "Speed"into the Serial Register
Ezequiel
___________________________
This message was ported from CCS's old forum
Original Post ID: 12717 |
|
|
Sherpa Doug Guest
|
Re: I Think I solve the Autobaud rate rutine |
Posted: Mon Mar 17, 2003 8:57 am |
|
|
:=Well, justo to remember I'm using a 16F76 at 20MHz, using the Hardware UART and I receive 0x55 from a terminal, which speed of comm. I don't know.
:=So I use the pin as a normal input, and wait the start bit, measure it, and two more bits. then take and average and load the baudrate directly to the Serial Port Register.
:=Here I the rutine
:=
:=Unsigned Int16 Count1,Count2,Count3,Speed
:=
:=While(RXPin){}
:=While(!RXpin) {
:= delay_us(1); //Think that some NOPs will be better
:= count1++;
:=}
:=While(RXpin){
:= delay_us(1);
:= count2++;
:=}
:=While(!RXpin){
:= delay_us(1);
:= count3++;
:=}
:=Speed = (Count1 + count2 + Count3) / 3
:=
:=//Well, and then I load the "Speed"into the Serial Register
:=
:=Ezequiel
The basic idea is good, but I might check that all three counts are about the same. If one is way off discard it.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12766 |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: I Think I solve the Autobaud rate rutine |
Posted: Mon Mar 17, 2003 9:24 am |
|
|
:=Well, justo to remember I'm using a 16F76 at 20MHz, using the Hardware UART and I receive 0x55 from a terminal, which speed of comm. I don't know.
:=So I use the pin as a normal input, and wait the start bit, measure it, and two more bits. then take and average and load the baudrate directly to the Serial Port Register.
:=Here I the rutine
:=
:=Unsigned Int16 Count1,Count2,Count3,Speed
:=
:=While(RXPin){}
:=While(!RXpin) {
:= delay_us(1); //Think that some NOPs will be better
:= count1++;
:=}
:=While(RXpin){
:= delay_us(1);
:= count2++;
:=}
:=While(!RXpin){
:= delay_us(1);
:= count3++;
:=}
:=Speed = (Count1 + count2 + Count3) / 3
:=
:=//Well, and then I load the "Speed"into the Serial Register
:=
:=Ezequiel
Concider this. Jump baud when count of framing errors reaches 32.
#int_RDA2
RDA_isr()
{int8 x;
if(bit_test(RS232_ERRORS,2))
{RS232_ERRORS=0;
++ChanBErrors;
if(bit_test(ChanBErrors,5))
BaudChanB();}
else
{x= fgetC(ChanB);
ChanBinBuff[ChanBinIndex++] = x;
set_timer1(ChanBtimeout);
bit_clear(*0xF9E,0);
enable_interrupts(int_TIMER3);}}
The function BaudChanB(); jumps to the next slower baud rate. Baud jumping stops when the correct rate is achieved.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12767 |
|
|
Acetoel Guest
|
Re: I Think I solve the Autobaud rate rutine |
Posted: Tue Mar 18, 2003 4:24 am |
|
|
Hi,
Neutone, I didn't understand your rutine. And just to remember I received 0x55 only one time.
Sherpa, How I can load that value directly into the hardware port register?
Thanks to everybody
Ezequiel
:=:=Well, justo to remember I'm using a 16F76 at 20MHz, using the Hardware UART and I receive 0x55 from a terminal, which speed of comm. I don't know.
:=:=So I use the pin as a normal input, and wait the start bit, measure it, and two more bits. then take and average and load the baudrate directly to the Serial Port Register.
:=:=Here I the rutine
:=:=
:=:=Unsigned Int16 Count1,Count2,Count3,Speed
:=:=
:=:=While(RXPin){}
:=:=While(!RXpin) {
:=:= delay_us(1); //Think that some NOPs will be better
:=:= count1++;
:=:=}
:=:=While(RXpin){
:=:= delay_us(1);
:=:= count2++;
:=:=}
:=:=While(!RXpin){
:=:= delay_us(1);
:=:= count3++;
:=:=}
:=:=Speed = (Count1 + count2 + Count3) / 3
:=:=
:=:=//Well, and then I load the "Speed"into the Serial Register
:=:=
:=:=Ezequiel
:=
:=The basic idea is good, but I might check that all three counts are about the same. If one is way off discard it.
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 12785 |
|
|
Sherpa Doug Guest
|
Re: I Think I solve the Autobaud rate rutine |
Posted: Tue Mar 18, 2003 8:43 am |
|
|
:=Hi,
:= Neutone, I didn't understand your rutine. And just to remember I received 0x55 only one time.
:= Sherpa, How I can load that value directly into the hardware port register?
:=Thanks to everybody
:=Ezequiel
:=
I have never done that. I just use the #useRS232 statements. I suggest you read the Microchip datasheet on your PIC. The UART registers should be well explained. Use #define to label the register's location and then write to it just like it was a port.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12787 |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: I Think I solve the Autobaud rate rutine |
Posted: Tue Mar 18, 2003 9:23 am |
|
|
:=Hi,
:= Neutone, I didn't understand your rutine. And just to remember I received 0x55 only one time.
:= Sherpa, How I can load that value directly into the hardware port register?
:=Thanks to everybody
:=Ezequiel
:=
:=:=:=Well, justo to remember I'm using a 16F76 at 20MHz, using the Hardware UART and I receive 0x55 from a terminal, which speed of comm. I don't know.
:=:=:=So I use the pin as a normal input, and wait the start bit, measure it, and two more bits. then take and average and load the baudrate directly to the Serial Port Register.
:=:=:=Here I the rutine
:=:=:=
:=:=:=Unsigned Int16 Count1,Count2,Count3,Speed
:=:=:=
:=:=:=While(RXPin){}
:=:=:=While(!RXpin) {
:=:=:= delay_us(1); //Think that some NOPs will be better
:=:=:= count1++;
:=:=:=}
:=:=:=While(RXpin){
:=:=:= delay_us(1);
:=:=:= count2++;
:=:=:=}
:=:=:=While(!RXpin){
:=:=:= delay_us(1);
:=:=:= count3++;
:=:=:=}
:=:=:=Speed = (Count1 + count2 + Count3) / 3
:=:=:=
:=:=:=//Well, and then I load the "Speed"into the Serial Register
:=:=:=
:=:=:=Ezequiel
:=:=
:=:=The basic idea is good, but I might check that all three counts are about the same. If one is way off discard it.
:=:=
What is the device you are communicating with? The routine I posted is based on recieving periodic packet transmition or bytes. Baud is adjusted untill incomming packets are free of framing errors.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12789 |
|
|
Acetoel Guest
|
Re: I Think I solve the Autobaud rate rutine |
Posted: Tue Mar 18, 2003 9:55 am |
|
|
I'm communication with a VW GOL Electronic Control Unit. This unit send 0x55 only one time, and the continue sending information, there is 30ms between I rcv 0x55 and the first byte of info. that is way I need to use 0x55 to detect the baudrate at ones.
Thanks
Ezequiel
:=:=Hi,
:=:= Neutone, I didn't understand your rutine. And just to remember I received 0x55 only one time.
:=:= Sherpa, How I can load that value directly into the hardware port register?
:=:=Thanks to everybody
:=:=Ezequiel
:=:=
:=:=:=:=Well, justo to remember I'm using a 16F76 at 20MHz, using the Hardware UART and I receive 0x55 from a terminal, which speed of comm. I don't know.
:=:=:=:=So I use the pin as a normal input, and wait the start bit, measure it, and two more bits. then take and average and load the baudrate directly to the Serial Port Register.
:=:=:=:=Here I the rutine
:=:=:=:=
:=:=:=:=Unsigned Int16 Count1,Count2,Count3,Speed
:=:=:=:=
:=:=:=:=While(RXPin){}
:=:=:=:=While(!RXpin) {
:=:=:=:= delay_us(1); //Think that some NOPs will be better
:=:=:=:= count1++;
:=:=:=:=}
:=:=:=:=While(RXpin){
:=:=:=:= delay_us(1);
:=:=:=:= count2++;
:=:=:=:=}
:=:=:=:=While(!RXpin){
:=:=:=:= delay_us(1);
:=:=:=:= count3++;
:=:=:=:=}
:=:=:=:=Speed = (Count1 + count2 + Count3) / 3
:=:=:=:=
:=:=:=:=//Well, and then I load the "Speed"into the Serial Register
:=:=:=:=
:=:=:=:=Ezequiel
:=:=:=
:=:=:=The basic idea is good, but I might check that all three counts are about the same. If one is way off discard it.
:=:=:=
:=
:=What is the device you are communicating with? The routine I posted is based on recieving periodic packet transmition or bytes. Baud is adjusted untill incomming packets are free of framing errors.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12792 |
|
|
|
|
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
|