-
Couldn't load subscription status.
- Fork 7.7k
Disable uart TX pin but use RX #11372
-
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!
Beta Was this translation helpful? Give feedback.
All reactions
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
-
@SuGlider PTAL
Beta Was this translation helpful? Give feedback.
All reactions
-
@handmade0octopus - I have created an issue from this topic. I'll handle it from there.
Beta Was this translation helpful? Give feedback.
All reactions
-
❤️ 1
-
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.
Beta Was this translation helpful? Give feedback.