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.

Basic query on "ROM_UARTCharPut"

Hi All.


I have been using the Tiva-Launchpad board, and flashed code that wrote to UART, and the same was displayed on the putty-terminal setup via serial-cable.

Things work fine.

I have a basic doubt though.

Right now, the serial-cable is connected, and all characters are seen on the putty-terminal.

If I disconnect the serial-cable, will "ROM_UARTCharPut" block forever (because there would be no consumer of the characters)? Do I need to use buffer-overflow checks with "ROM_UARTCharPut", so that my application does not hang when the serial-cable is disconnected?

Will be grateful for any pointers.

Thanks and Regards,

Ajay

  • Ajay Garg said:
    If I disconnect the serial-cable, will "ROM_UARTCharPut" block forever

    The hardware cannot tell if there is anything connected.

    Robert

  • Thanks Robert for the reply.

    Sorry, I didn't get you :(

    Please verify/reject my understanding ::

    1)
    ROM_UARTCharPut writes to the write-buffer (waiting for it to have some space if full).

    2)
    At anytime, the contents of the write-buffer are written (sequentially of course) to the UART/GPIO pin (at the BAUD rate specified during UART-setup).

    Once byte-numbered "n" comes to the UART/GPIO pin, the byte-numbered "n-1" is overwritten.

    3)
    It does not matter if a serial-cable is connected or not.

    If it is connected, the character CURRENTLY at the UART/GPIO pin will be displayed on the terminal.
    If it is disconnected, nothing happens.


    4)
    In summary, irrespective of whether the serial-cable is connected or not, ROM_UARTCharPut will NEVER cause the application to hang indefinitely.


    Are my understandings correct?
  • Ajay Garg said:
    If I disconnect the serial-cable, will "ROM_UARTCharPut" block forever (because there would be no consumer of the characters)?

    Ajay Garg said:
    Sorry, I didn't get you :(

    Consider: If the hardware doesn't know whether a cable is connected how else is the peripheral to know?

    Robert

  • Hello Ajay,

    UART is the simplest of all protocols but does not have a mechanism to detect a cable connect/disconnect. And since it lacks the definition, there are numerous implementation of it. In this case the RX pin is floating causing it to come to a Logic Low level (there is always a discharge path paristically). If you can connect a Pull Up on the RX line, or enable the GPIO Weak Pull on the RX line, then it will allow for a transmission.

    Alternatively, you can enable a Pull Down with interrupt generation on logic low level. So if the cable is not connected or disconnected a GPIO interrupt can let you know if the cable has been removed and corrective action taken.

    Regards
    Amit
  • Robert Adsett said:
    The hardware cannot tell if there is anything connected.

    The TM4C123 UART1 supports hardware flow-control. If the CTSEN bit is set the The U1CTS input controls the transmitter. The transmitter may only transmit data when the U1CTS input is asserted.

    In this case, not sure if hardware flow control is enabled.

  • Hello Chester

    I really doubt that the Flow Control is being used in this post... Lack of understanding is more evident for UART to be PnP.

    Regards
    Amit