Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Disable uart TX pin but use RX #11372

Answered by SuGlider
handmade0octopus asked this question in Q&A
Discussion options

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!

You must be logged in to vote

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 ...

Replies: 3 comments

Comment options

@SuGlider PTAL

You must be logged in to vote
0 replies
Comment options

@handmade0octopus - I have created an issue from this topic. I'll handle it from there.

You must be logged in to vote
0 replies
Comment options

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.

You must be logged in to vote
0 replies
Answer selected by handmade0octopus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /