Skip to main content
Visitor II
April 19, 2007
Question

UART tansmission erroe when baud rate above 9600 bps?

  • April 19, 2007
  • 2 replies
  • 762 views
Posted on April 19, 2007 at 10:08

UART tansmission erroe when baud rate above 9600 bps?

    This topic has been closed for replies.

    2 replies

    hg-chenAuthor
    Visitor II
    April 19, 2007
    Posted on April 19, 2007 at 09:42

    STR711FR2 us used,

    when setting UART at baud rate 9600 bps,it works fine,

    but above 9600 bps, transmission data received become scramble!

    any advise?

    setting as below,

    //----------------------------------------------------------------Uart2 config

    /* GPIO peripheral configuration -------------------------------------------*/

    /* Configure the GPIO pins */

    GPIO_Config(GPIO0, UART2_Tx_Pin, GPIO_AF_PP);

    GPIO_Config(GPIO0, UART2_Rx_Pin, GPIO_IN_TRI_CMOS);

    /* UART peripheral configuration -------------------------------------------*/

    /* Configure the UART X */

    /* Turn UART0 on */

    UART_OnOffConfig(UART2, ENABLE);

    /* Disable FIFOs */

    UART_FifoConfig (UART2, DISABLE);

    /* Reset the UART_RxFIFO */

    UART_FifoReset (UART2 , UART_RxFIFO);

    /* Reset the UART_TxFIFO */

    UART_FifoReset (UART2 , UART_TxFIFO);

    /* Disable Loop Back */

    UART_LoopBackConfig(UART2 , DISABLE);

    /* Configure the UART0 as following:

    - Baudrate = 115200 Bps

    - No parity

    - 8 data bits

    - 1 stop bit */

    UART_Config(UART2,19200,UART_NO_PARITY,UART_1_StopBits,UARTM_8D);

    /* Enable Rx */

    UART_RxConfig(UART2 ,ENABLE);

    Visitor II
    April 19, 2007
    Posted on April 19, 2007 at 10:08

    Given a certain APB clock frequency, possible baud rates are limited to a series of values:

    BaudRate = Fapb / (16 * UARTn_BR), UARTn_BR = 1, 2, 3, ..., 65535

    See Reference Manual for details.

    When the difference between baud rates on the transmitting and receiving sides exceeds a certain limit, errors in reception occur.

    In order to be able to precisely generate standard baud rates like 9600, 19200, 38400, 57600, 115200 and so on you have to use a special frequency for MCU clock, like 7.3728 MHz.

    Regards,

    - mike