ColdFire: Fix UART baudrate formula
The formula "counter = (u32) (gd->bus_clk / gd->baudrate) / 32" can generate the wrong divisor due to integer division truncation. Round the calculated divisor value by adding 1/2 the baudrate before dividing by the baudrate. Signed-off-by: TsiChung Liew <Tsi-Chung.Liew@freescale.com> Acked-by: Gerald Van Baren <vanbaren@cideas.com>
This commit is contained in:
parent
9b55a25369
commit
81cc32322a
|
@ -63,8 +63,8 @@ int serial_init(void)
|
|||
uart->umr = UART_UMR_SB_STOP_BITS_1;
|
||||
|
||||
/* Setting up BaudRate */
|
||||
counter = (u32) (gd->bus_clk / (gd->baudrate));
|
||||
counter >>= 5;
|
||||
counter = (u32) ((gd->bus_clk / 32) + (gd->baudrate / 2));
|
||||
counter = counter / gd->baudrate;
|
||||
|
||||
/* write to CTUR: divide counter upper byte */
|
||||
uart->ubg1 = (u8) ((counter & 0xff00) >> 8);
|
||||
|
|
Loading…
Reference in a new issue