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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 :(
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
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
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.
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.
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
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.
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 :(