[uClinux-dev] serial port (RS-232) baudrate issue
gerg at snapgear.com
Wed Jun 1 07:56:56 EDT 2011
On 01/06/11 18:14, Salvatore Frizzoli - IMS Italy wrote:
> thank you for the accurate response. We use a Coldfire 5234. I have seen
> on the Coldfire manual and the uClinux code (kernel 2.6.x).
> Making some computations, we have seen that our 57600 baudrate is
> changed by our micro to 57165 bps. In fact, the formula to compute the
> divisor is:
> Divisor = BusClock / (32 * baudrate)
> In our case, BusClock = 75 Mhz, baudrate = 57600, so Divisor = 41.
> Thus, the real baudrate is 75000000 / (32 * 41) = 57165 bps.
> We could try to change divisor to 40 to have a 58594 bps baudrate, but
> it's not so useful for our purposes.
> We will try other solutions.
I have seen people use a different speed crystal that gives them
more favorable divisors - and so more accurate baud rates. Not a
solution that may be practical or useful to you though :-(
> Il 01/06/2011 3.38, Greg Ungerer ha scritto:
>> Hi Salvatore,
>> On 31/05/11 22:29, Salvatore Frizzoli - IMS Italy wrote:
>>> I have an issue to the RS232 serial port on a Coldfire board equipped
>>> with uClinux. I have set the serial port with a baudrate of 57600 bps,
>>> it is connected to a third-party device, but it doesn't work (all
>>> charachters are corrupted). If I connect a PC directly to the device
>>> with 57600 bps, it works.
>>> If the bps is put down to 19200, also the connection by the board works.
>> Yeah, in most cases the ColdFire generated baud rates will not be
>> very accurate. They are a simple division of the CPU clock, so it
>> is easy to work out what exact baud rate you will see for a specific
>> baud setting. And faster baud rates usually have larger errors.
>> If you email your ColdFire CPU type and the clock you are driving
>> it with we could quickly figure it out.
>> (* One caveat is the 5272, which has a fine grained baud rate
>> setting as well)
>>> This is due to the fact that the third party device probably has a
>>> baudrate lightly different from 57600 bps and the PC serail port can
>>> adjust its frequency according to the device one, while Coldfire cannot.
>>> My question is: is there a way to configure the serial port by uClinux
>>> such that also Coldfire can adjust its frequency?
>>> Alternatively, can I configure the serial port with a baudrate slightly
>>> different from the standard ones (for example: 57500 in place of 57600)?
>> You could easily modify the clock and divisor code for the serial
>> driver. Have a look at the code (depends on which kernel version
>> where the driver source is linux-2.4.x/drivers/char/mcfserial.c,
>> or linux-2.6.x/drivers/serial/mcf.c or even
>> linux-2.6.x/drivers/tty/serial/mcf.c for the very latest 2.6 kernels).
>> Greg Ungerer -- Principal Engineer EMAIL: gerg at snapgear.com
>> SnapGear Group, McAfee PHONE: +61 7 3435 2888
>> 8 Gardner Close FAX: +61 7 3217 5323
>> Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com
More information about the uClinux-dev