This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UART doesn't work

Hey,

I have a problem with my UART. It runs as long as the RS232-Cable to the PC is connected, but once I unplug it(i.e. the TxD and RxD Pins are open), the UART stops sending data. Is this a correct behaviour or am I doing something wrong?

  • Errr... without a cable connected, how do you know that it's not transmitting?!

  • lol, I've got a scope attached;)

  • RS-232 is not hot-pluggable. If you do this, there is an (albeit remote) chance of damaging your hardware, or other kinds of misbehavior.

  • once I unplug it(i.e. the TxD and RxD Pins are open), the UART stops sending data. Is this a correct behaviour or am I doing something wrong?

    make a small program as sketched below

    initilaize UART
    TI = 1;
    while (1)
    { if (TI)
    ( TI = 0;
    SBUF = 0x55;
    }

    If that does not pulse your Txd you have a REAL MYSTERY.

    My guess is that something in your full code stop transmitting for some reason when nothing is received.

    Erik

  • "It runs as long as the RS232-Cable to the PC is connected, but once I unplug it(i.e. the TxD and RxD Pins are open)"

    You're not connecting the microcontroller's TxD and RxD Pins direct to RS232, are you...? :-0

    You do have an RS232 transceiver (eg, MAX232) between the microcontroller's Pins and the RS232, don't you...? :-0

  • "..., but once I unplug it..., the UART stops sending data."

    How exactly is your PC setup? Do you have a dumb terminal at the PC side or do you have a app-specific program?

    Is your code just echoing the chars you type in the PC terminal program?

    If you have a slave protocol running on the uC, your UART may be stopped simply because of flow control or protocol issues.

    If you are hot-unplugging the RS232 cable, your UART may just get framing errors, and stall the serial link. To prevent this, you must check for framing errors (read the FE bit) in the UART receive handler, and reset the UART in such cases.

  • Not much information here.

    Are you metering the UART on the uC directly, an external UART, or a line driver like the MAX232 to translate CMOS or TTL into the RS232 voltages?

    Like erik has mentioned, your code may be designed in such a way that without received data, it will never transmit anything.

    Your external hardware may be using hardware flow control like RTS/CTS, and the CTS line on the non-PC side is just floating.