Send string using different SCI baud rate

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Send string using different SCI baud rate

3,418 Views
gambler
Contributor I
Hello,
 
My task is very simple. I wish to send out  a string for few sci baud rate (1200,2400, 4800, 9600, 119200). The problem is that only the first baud rate(119200) will be send out correctly, for the other baud rate, i get junk character.
 
Here is my code:
 
FIND_ETH_BR   CLR       SCI1BDH
              MOV       #%00100000,SCI1BDL      ; baud rate 384000
              CLRA
              STA       SCI1C1          ;SCI Control Register 1
              STA       SCI1C3          ;SCI Control Register 3              
              
             
FIND_ETH_BR1              
              LDA       SCI1BDL         ;Change baud rate (divide by 2)
              LDX       SCI1BDH
              LSLA
              ROLX
              STX       SCI1BDH
              STA       SCI1BDL
              CBEQX     #$08,FIND_ETH_BRQ
              LDA       #%00101100      ;Enable RIE , TIE
              STA       SCI1C2          ;SCI Control Register 2
              LDA       SCI1S1          ;Clear byte
              JSR       Send_String
              BRA       FIND_ETH_BR1
FIND_ETH_BRQ  RTS  
 
 
Is there anything wrong with my code??
Thanks.
 
Rgds,
Gan
 
Labels (1)
0 Kudos
7 Replies

834 Views
Sten
Contributor IV
I haven't checked your code (you didn't mention which pocessor you are using, so it is impossible to check), but one thing did come in my mind; Is your receiver fast enough to switch baudrates in it's end? It will happen very fast in the transmitter end, and there will be actually no time for the receiver to switch baudrate and start waiting for start bits. Perhaps you should, in addition to of course wait till the last character really is shifted out, also let the transmitter idle for the time of a few characters after switching baudrates, so that the receiver will have time to do it's stuff.
 
0 Kudos

834 Views
gambler
Contributor I
Hi there,

 Sorry for the incomplete information. I was using s08AW32. In the receiver end, i'm using pc terminal software. So, it should be fast enough. I will try to add some delay on my code and see how's it going.

Thanks a lot....
0 Kudos

834 Views
peg
Senior Contributor IV
Hi Gambler,
 
How does the PC end know when and what to switch its baudrate to?
Different baudrates (especially *2 & /2) easily mimic some other byte at the wrong rate.
 
0 Kudos

834 Views
mke_et
Contributor IV
I wouldn't be surprised if this was a 'speed select' routine. The kind where the 'box' transmits messages like 'if you can read this, hit enter' and when you see the message in clear text on your terminal, your hitting enter tells the box to use that baud rate.

Or... He's trying to do something like an OBDII interface that requires some wierd baud changes on init...

The question really becomes is this something new the guy is trying to do, or is he trying to figure out how to do something that is already established and he can't link to it.
0 Kudos

834 Views
peg
Senior Contributor IV
Yes, I figured it might be something like this.
I have never done it (used many) but I would have thought that one requirement would be to leave the line idle for a couple of byte times of the slowest baudrate in between rate changes.
 
0 Kudos

834 Views
gambler
Contributor I
Yes, i am writting something similar to 'speed select' routine. Thanks to you guys, i have solve my problem. I let the line idle for few character before i change baud rate and it works.
 
Thanks!!
0 Kudos

834 Views
mke_et
Contributor IV
When doing tricks like this, there are a couple of things you need to keep in mind.

Always be careful to wait for each character to be out and gone before you try to change the baud rate. That means TOTALLY out the pin, not just out of a holding register.

Also, realize that at the receiving end, you might still need to meet the requirement of a 'stop bit' or weird things may appear to be happening.

Message Edited by mke_et on 2007-11-06 10:01 PM
0 Kudos