Serial port multiplexing

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
liudr
Posts: 211
Joined: Tue Oct 17, 2017 5:18 am

Serial port multiplexing

Post by liudr » 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.

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: Serial port multiplexing

Post by jickster » Mon Sep 10, 2018 9:28 pm

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

User avatar
liudr
Posts: 211
Joined: Tue Oct 17, 2017 5:18 am

Re: Serial port multiplexing

Post by liudr » 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? 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().

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: Serial port multiplexing

Post by jickster » Mon Sep 10, 2018 9:55 pm

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.

Post Reply