View Full Version : Baud Rate Converter
paul.mcallister
- 14th June 2008, 19:06
Hi All,
I need to convert a serial data stream from 9600 baud to 1200 baud. I was wondering if any one has attempted this and could share some code or tips. I am using PIC Basic Pro and the target processor is a 16F876A
Thanks in advance, Paul
mackrackit
- 14th June 2008, 20:01
How much data at a time? And is it always the same (if string) length?
Could receive into EEPROM at one rate, then send from EEPROM at the other.
Do the same with an array.
paul.mcallister
- 15th June 2008, 00:15
Hi Dave,
Thanks for you thoughts. I believe that the string lengths are the same and the content is constant, but I will need to do some testing to make sure.
My initial thought was to read the string into and 8*String_length array on one serial input port defined at 9600 baud, discard 7 of the array elements and transmit the 8th element on another serial port defined as 1200 baud and loop back.
Actually the above approach may be over engineering it. It might be as simple as reading in the string, retransmitting it and when its done, go get another string.
My reason that I posed the question to the forum is that I suspect that someone has figured this out before, probably with a far more elegant solution than my idea. I just didn't want to re invent the wheel.
Regards, Paul
skimask
- 15th June 2008, 00:26
Find out what the strings actually look like. You can probably set it up to 'trigger' on a certain byte and take the next byte or the next one, whatever.
Other than that, yes, grab 8, throw 7, send out the 8th. That'll work, as long as the 9600 baud isn't coming in fast enough to overwhelm the 1200 baud data. You could do it completely in software (SERIN/SEROUT) as long as the timing permits and NOTHING could possibly overlap, otherwise, you'll end up using either a combination of hardware/software serial comm's, or maybe some external 'steering' logic...grab the 9600 baud, re-do the baud rate registers, steer the data, send the 1200 baud, re-do the baud registers, re-steer the data, grab the 9600...and so on...
Actually, since you are only RECEIVING 9600 and SENDING 1200, you probably wouldn't have to do any steering at all. Just use the same hardware serial port for both, 9600 on the RX, 1200 on the TX, switch baud rates in mid-stream. Shouldn't be too difficult.
Powered by vBulletin® Version 4.1.7 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.