This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

change the UART setting in run time



Hello,

I'm using CCS  Version: 6.1.0.00104, TIRTOS: tirtos_tivac_2_14_04_31 with TM4C129.

and i want to change the serial port configuration in the run time like changing the baudrate from value to another. so the program start up with a hardcoded configuration for the UART 9600,8,1 and it works properly with this baudrate but when trying to change the baudrate by invoking UARTConfigSetExpClk, it stuck forever and with more investigation i found that  UARTConfigSetExpClk invoks UARTDisable which have the following loop

while(HWREG(ui32Base + UART_O_FR) & UART_FR_BUSY)
{
}

it seems that the is keeping busy and there is no way to clear it. any idea?

Thnaks,

Mohammed Fawzy

  • Hi Mohammed,

    TI-RTOS drivers currently do not support dynamically changing the baud rate while the driver is open.  To safely change the baud rate, you should close the instance & reopen it with the new baud rate.  This will ensure all driver internals & registers are configured correctly.  

    Mohammed Fawzy said:

    while(HWREG(ui32Base + UART_O_FR) & UART_FR_BUSY)

    {
    }

    it seems that the is keeping busy and there is no way to clear it. any idea?

    Page 1182 of the device datasheet states this bit is set by hardware to indicate that the UART is busy transmitting data, I do not think there is a way of clearing this bit.  Instead, you should probably check to make sure that all reads/writes have completed before you proceed with trying to change the baud rate.

    Hope this helps,

    -- Emmanuel

  • Hi Emmanuel,

    actually the serial port wasn't transmitting but somehow i passed wrong parameter to UARTConfigSetExpClk that cause the serial port behaving as not expected and was setting this bit but the most funny thing that even if i did reset to the microcontroller, it won't clear this bit.
    and before i discovering this mistake, i was able to get out from this dilemma by invoking SysCtlPeripheralReset for this serial port.

    Thanks for your help
    Mohammed Fawzy