Page 1 of 1

Serial port multiplexing

Posted: Mon Sep 10, 2018 4:49 am
by liudr
I am thinking about this scenario where I need more than 2 serial ports, (not gonna touch the one running REPL). I've done this on a dev board, activate a serial port with machine.UART() one a pair of pins. Then activate the port on another two pins. It works. However, I'm trying to do it safely. When I change pins using init(), will the previous pins be put in high impedance mode with pull-down resistors to prevent spurious readings? Shall I do this to the pins before calling init() to use new pins? Can someone point me to the source code to read? Thanks.

Re: Serial port multiplexing

Posted: Mon Sep 10, 2018 9:28 pm
by jickster
liudr wrote:
Mon Sep 10, 2018 4:49 am
I am thinking about this scenario where I need more than 2 serial ports, (not gonna touch the one running REPL). I've done this on a dev board, activate a serial port with machine.UART() one a pair of pins. Then activate the port on another two pins. It works. However, I'm trying to do it safely. When I change pins using init(), will the previous pins be put in high impedance mode with pull-down resistors to prevent spurious readings? Shall I do this to the pins before calling init() to use new pins? Can someone point me to the source code to read? Thanks.
https://github.com/micropython/micropyt ... uart.c#L67

Re: Serial port multiplexing

Posted: Mon Sep 10, 2018 9:48 pm
by liudr
Thanks! I was able to understand the code, which uses uart_set_pin() to set pins. I couldn't find uart_set_pin() in the repo. Could you help? Anyway, it doesn't seem to handle past pins, such as setting them to I or T with pull-down. I guess I'll have to do that myself right before switching the pins with machine.UART.init().

Re: Serial port multiplexing

Posted: Mon Sep 10, 2018 9:55 pm
by jickster
liudr wrote:
Mon Sep 10, 2018 9:48 pm
Thanks! I was able to understand the code, which uses uart_set_pin() to set pins. I couldn't find uart_set_pin() in the repo. Could you help?
If it's not in the repo - https://github.com/micropython/micropyt ... rt_set_pin - and it's not then that means it's a ESP32 SDK function

https://docs.espressif.com/projects/esp ... /uart.html
liudr wrote:
Mon Sep 10, 2018 9:48 pm
Anyway, it doesn't seem to handle past pins, such as setting them to I or T with pull-down.
I'm not familiar with UART and associated issues so I don't know what you mean by that. Please clarify.

EDIT: Ok I get the issue; I don't know. If the issue is not mentioned on the espressif.com website . . . maybe it's not an issue? That's a complete guess.