RS-232 signals inverted with QSerialPort



  • I have written a program to download some data/settings to a MCU on a PCB through RS-232 communication. On the PC-side, I use a USB-to-serial converter. The application has been running with problems for 2 - 3 months with only minor edits here and there and nothing related to the port initialization.
    This week, the communication stopped working. My MCU received data very different from what was expected. The header bytes is 0xAB and my board gets 0x3F. By using of my PC scope and its serial decoder,, I was able to determine the the serial signals are inverted, namely, the idle state is -12v and the start bit goes high to 12v, rather than the standard (opposite) levels of idle high with start bit going low. I have looked around for a setting that perhaps I didn't set when I initialize the port but can't seem to find anything that relates to inverting the RS-232 levels. I have repeated the problem on two different computers (one Mac, one PC) with two separate USB-to-serial converters. Does anyone have any ideas?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Sounds rather like hardware related. What version of Qt and OS are you running ?

    @kuzulis does this remind you of something ?



  • I was able to determine the the serial signals are inverted, namely, the idle state is -12v and the start bit goes high to 12v

    What is signals? Is It Rx/Tx?

    @kuzulis does this remind you of something ?

    No. Most likelly, it is HW issue.



  • After further troubleshooting, I think the issue is on the board side, probably hardware as suggested. The RS-232 levels coming out of the USB-to-serial are correct but they are not being inverted by the level shifter. In addition, the RX pin on the MCU is idle low, when it should be idle high.



  • I still don't know the cause but the TTL levels going into the board are definitely inverted. Fortunately my MCU offers an option to invert the TTL RX which negates the inverted levels and allows me to bypass the issue in the short term.



  • The odds of the signal levels being inverted are very unlikely. You mentioned you are using a PC scope. My guess is you have the gnd/signal connections swapped and this would make it look inverted. Could be a software setting that inverts the signal too. A simple way to test this is to connect an AA battery to the input as you know which ends of the battery are positive and negative.

    I would suggest replacing your 'device' with another computer that has a serial port and some sort of serial terminal (like Hyperterminal). It sounds like it is working but there is something wrong which is why you started looking at this with a scope. If you have the time you could write a software simulator that would emulate the hardware you are trying to talk to so you can bypass all the clumsy stuff (like USB-Serial adapters, cables, actual device, ...).


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.