Menu

hot pluggable usart usage

Help
2019-04-30
2019-05-01
  • Jim giordano

    Jim giordano - 2019-04-30

    I would like to make it so that I can plug into a device as needed (tx,rx,gnd), when I need to check something out. When I currently unplug the lines from the microprocessor, it just hangs up the next time it trys to do an HSerPrint. I couldn't find a status bit saying the eusart was ready and able to do a transmit, so I don't know what to check to see if it's valid to do the HSerPrint. (This happens to be on a 16LF18324 but it's probably a generic problem). All the bits I see in the documentation are one's the user sets to transmit a byte, not weither the hardware is actually ready to do so. If there is one, what is the name of the bit to check?

     
  • Chris Roper

    Chris Roper - 2019-04-30

    There is no way for the EUSART to know if it has a serial device is plugged in or not so it has no bit to say that a connection is possible.
    That said, you could possibly use another Pin, with appropriate external circuitry, to look for an Idle bit on the Rx Pin of the EUSART and check that before sending, preferably you would be looking for a signal held high.

    Cheers
    Chris

     

    Last edit: Chris Roper 2019-04-30
  • Jim giordano

    Jim giordano - 2019-04-30

    Thanks Chris.
    It sure seems like it knows it can't send because it locks up the microprocessor and doesn't move on, so it's obviously waiting for something. Oh well, the extra pin is certainly an easy solution, just jumper it to the ground pin, pulling it low when the plug is plugged in.

     
  • Chris Roper

    Chris Roper - 2019-04-30

    Without delving into the actual code that the compiler generates I can only guess that it is waiting for the Tx Bit to clear, meaning that the Tx Register is empty and Ready for a new Character.
    I am sure you can override it and use a timeout but you would need to look in the help for that.
    A combination of sending a byte and waiting for a timeout whilst looking at the Tx Flag could be a way of Detecting a valid serial device too. But the receiving end would have to know what to do with the test char it receives.

     
  • mmotte

    mmotte - 2019-05-01

    Jim,
    I would not think the transmitter would hang the program. It can't sense what is on the Tx port. It does hold the program from sending another byte to the TXReg but only is looking for the empty TxReg which is internal.
    It may be holding up on the receive part. What is connected to the Rx port when disconnect from a unit? is it buffered with like a MAX232? Is it floating and causing overrun or framing errs?
    We need to know more about the program.

    Mike

     
  • Jim giordano

    Jim giordano - 2019-05-01

    Nope. Not reading at all. Not sending from the pc. Nothing connected to the rx pin. I have read successfully recently, but I comment all that code out as it wouldn't be used in the final application.
    I just double checked by disconnecting only the rx and leaving only the tx and ground connected and it still worked perfectly.

     
  • Jim giordano

    Jim giordano - 2019-05-01

    Okay. That's weird. It's now working the way it was intended with no changes. Iswear it wasn't working before and I tried everything I could think of over several hours and it would not work. Once the serial plug was pulled, the processor locked up and wouldn't restart. I just tried it again and now it's working. I can pull the plug, tell it to print something (via pushbutton), plug it back into the pc and it will print when needed. ????? Sorry for wasting everyones time.

    ps
    Please don't consider me the boy who cried wolf, I honestly thought it wasn't working :(

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.