Skip to content

Disable uart TX pin but use RX #11380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SuGlider opened this issue May 20, 2025 · 4 comments
Closed

Disable uart TX pin but use RX #11380

SuGlider opened this issue May 20, 2025 · 4 comments
Assignees

Comments

@SuGlider
Copy link
Collaborator

Discussed in #11372

Originally posted by handmade0octopus May 16, 2025
Hello!
Slowly moving from 2.X.X arduino (finally).

Question about uart though. Before I used .end(true) to completely detach pins as I only want to use RX part of the Serial as one of my pins is used for dual purpose at boot.

Seems like with new changes I am not able to do that and begin when passed -1 will always default to some pin.

Is there workaround for this or maybe we can get back .end(true) that will also set the pins to value to not use it at all?

Here is simple code of what I am talking about:

Serial1.begin(115200, SERIAL_8N1, ENC_B, I2C_SCL);
Serial1.end(); // before - .end(true);
Serial1.begin(115200, SERIAL_8N1, ENC_B, -1);

Thanks for all the help!

@SuGlider SuGlider self-assigned this May 20, 2025
@SuGlider
Copy link
Collaborator Author

@handmade0octopus - I'll investigate it and get back here.

@SuGlider
Copy link
Collaborator Author

@handmade0octopus, yes the sketch work correctly using Arduino Core 3.2.0
When Log Level is Debug, the output matches the expected results (ENC_8 was set as pin 4 and no TX[1] is set):

------------------------------------------
GPIO Info:
------------------------------------------
  GPIO : BUS_TYPE[bus/unit][chan]
  --------------------------------------  
     4 : UART_RX[1]
    43 : UART_TX[0]
    44 : UART_RX[0]
============ After Setup End =============

@SuGlider
Copy link
Collaborator Author

Serial1.end() completely detaches all the UART1 pins (rx, tx, cts, rts).
Serial1.begin(115200, SERIAL_8N1, RX1_Pin) will only set RX pin and leave TX pin not attached to any GPIO.

@SuGlider
Copy link
Collaborator Author

Tested using Arduino Core 3.0.7, 3.1.3 and 3.2.0:

Serial1.end() completely detaches all the UART1 pins (rx, tx, cts, rts).

Serial1.begin(115200, SERIAL_8N1, RX1_Pin) or Serial1.begin(115200, SERIAL_8N1, RX1_Pin, -1) will only set RX1 pin and leave TX1 pin as unchanged.

If Serial1.end() was called before, TX1 will detached and Serial1.begin(115200, SERIAL_8N1, RX1_Pin) not attach TX1 to any GPIO.

But if Serial1.begin(115200, SERIAL_8N1, ENC_B, I2C_SCL) folllowed by Serial1.begin(115200, SERIAL_8N1, NewRX1_pin) with no Serial1.end() in between, it will keep the previous TX1 attached as by the first begin(). Therefore, the final result would be RX1 = NewRX1_pin and TX1 = I2C_SCL (set in the first begin())

Only when both are -1, like in Serial1.begin(115200) for the first time or after a Serial1.end() is when both will be set to their default UART1 pins. Otherwise, it will just change the baudrate and keep previous RX1 and TX1. This is compatible with Arduino API behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant