Using RX and TX on a single serial port for seperate devices.

Im running low on pins and only need the RX on one port to listen for the GPS output, it occurred to me that I could use the unused TX on that as a simple debug output.

Will i get potential corruption if I debug during GPS reads ?

Im worried it might be one of those things that "mostly" works until it sometimes doesnt, so my testing wont show the whole picture.

The chip in this case is the ATTINY1634.

thankyou.

As long as you are happy with using the baudrate of the GPS module for TX you will be fine. The data registers of the UART for TX and RX are at the same address location but they are separate.

Klaus_K:
As long as you are happy with using the baudrate of the GPS module for TX you will be fine. The data registers of the UART for TX and RX are at the same address location but they are separate.

Thanks for that.

No, you shouldn't use the tx pin for other purpose when you are using the RX pin for communication and the communication is on. It can cause a malfunction in the Arduino. Please don't do that.

ArnavPawarAA:
It can cause a malfunction in the Arduino. Please don't do that.

Exactly how? I find it extremely hard to believe

When the Serial pins are used for communicating, the AVR RX pin has to recieve, so it is set to a input pin. The TX pin has to transmit anything which the Arduino has to. So, when the Arduino has nothing to send, it keeps the TX pin low (according to the serial library). So if you go to use it for any other purpose, and when you try to keep that pin high, then the serial library will force it to low. Because of this, a conflict will happen between your code and the serial library. Whenever the command is recieved to put the pin high, the pin will be high for a very short time and it will automatically put high. It could cause a malfunction so don't go to do it. Use any other microcontroller if you are running out of pins.

But this will happen if you use that pin with a digital IO command. If you want to use that pin for serial communication with any other device, the you can give serial.print command to communicate with the third device. Reply if any questions.

ArnavPawarAA:
When the Serial pins are used for communicating, the AVR RX pin has to recieve, so it is set to a input pin. The TX pin has to transmit anything which the Arduino has to. So, when the Arduino has nothing to send, it keeps the TX pin low (according to the serial library). So if you go to use it for any other purpose, and when you try to keep that pin high, then the serial library will force it to low. Because of this, a conflict will happen between your code and the serial library. Whenever the command is recieved to put the pin high, the pin will be high for a very short time and it will automatically put high. It could cause a malfunction so don’t go to do it. Use any other microcontroller if you are running out of pins.

But this will happen if you use that pin with a digital IO command. If you want to use that pin for serial communication with any other device, the you can give serial.print command to communicate with the third device. Reply if any questions.

In my case I wish to use it as a Serial TX pin, just not to the same device that the RX pin is connected.

Ok ok then you can use it. This means that the RX pin will be connected to the GPS module and the TX will be used to transmit data to another device. It can work. But you will be only transmit to the other device and couldn't reicieve from it. So you can do it. You will use Serial.read for the GPS module and Serial.print for the other device.

ArnavPawarAA:
So, when the Arduino has nothing to send, it keeps the TX pin low (according to the serial library).

That is incorrect. The Serial TX line is HIGH in the idle state.

...R

I am certain you can use both pins simultaneously. The device is designed to be able to transmit and receive at the same time. The datasheet specifically describes the USART as "full duplex". This explicitly means the ability to transmit and receive at the same time.

Case in point: you can bridge the pins together and have the device transmit to itself and it will receive its own output reliably.