8 UARTs using asm_pio / PIO / DMA / Micropython on the rPI Pico - Page 1
Forum section: electronics / general

author: spostma
author_rank: Regular Contributor
timestamp: August 13, 2022, 05:54:22 am
content: just a link to another interesting rPi Pico project to bit-bang 8 UARTsusing the PIO state machine coprocessor (German site):https://www.mikrocontroller.net/topic/540256I think that one could extend this to 32 UARTS using 4 PIOs if needed to make massive serial port server!

author: voltsandjolts
author_rank: Unknown
timestamp: August 13, 2022, 06:58:07 am
content: Google translation of that page:https://www-mikrocontroller-net.translate.goog/topic/540256?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-US&_x_tr_pto=wapp

author: pcprogrammer
author_rank: Super Contributor
timestamp: August 13, 2022, 07:36:29 am
content: Might be good for a MIDI switch for the musical instrument enthusiasts. You need to throw in a bunch of opto couplers and ttl inverters but for other serial application you would most likely also need extra hardware.

author: westfw
author_rank: Super Contributor
timestamp: August 13, 2022, 08:37:38 pm
content: QuoteThere are only 2 PIOs in a rp2040.Each PIO has 4 state machines, and it looks like their code is using one state-machine for each direction of each UART. So it's eight half-uarts, rather than 8 full uarts, (I'm not SURE, since the combination of python, PIO, and German is difficult for me to wade through...)

author: mino-fm
author_rank: Regular Contributor
timestamp: August 14, 2022, 07:26:22 am
content: Quote from: westfw on August 13, 2022, 08:37:38 pmThat's right.

author: westfw
author_rank: Super Contributor
timestamp: August 14, 2022, 07:48:30 am
content: I've wondered if you can two 8 transmitters in one PIO, as long at the bitrate is the same for all of them.For receivers, you want to detect the edge of the startbit as accurately as possible, and it can be in a different place on each Rx line. But for transmission, you wouldn't care if the bit edges are all in the same place.I'm not sure that it would work for real-world use, but for talking to a bunch of "serial" listen-only peripherals (Serial LCD, etc. As popularized by the BASIC Stamp which could do SEROUT on any pin), it could be useful.

author: spostma
author_rank: Regular Contributor
timestamp: August 15, 2022, 03:25:36 pm
content: thank you for your corrections!the readme.pdf says google-translated from German'With the PIO's you can connect up to 8 additional UART interfaces (alternatively as set up a transmitter or receiver)on freely selectable pins of the PI PICO, in addition to the two existing interfaces.'So up to 4 additional full duplex UARTs are possible with the source as it is now (4x RX channels + 4x Tx channels).From the PIO setup code it seems that one PIO can handle 4 channels,so 8 channels would usetwoPIO units:PIOx_BASE = 0x50200000 + ((smNumber >> 2) << 20)PIOx_RXFx = PIOx_BASE + 0x20 + ((smNumber & 3) * 4)However,https://www.raspberrypi.com/products/rp2040/specifications/states the RP2040 PIO specs:'8 × Programmable I/O (PIO) state machinesfor custom peripheral support'So I still get the impression that 16 additional full duplex channels would be possible using all 8 PIO state machines.---It seems that each channel can have its own baudrate, for it is a separate initialisation parameter for each channel.

author: westfw
author_rank: Super Contributor
timestamp: August 16, 2022, 01:42:01 am
content: QuoteTwo "state machines."QuoteYou're confusing "PIO Units" with "PIO State machines." The data sheet (Section 3.1: PIO Overview) says:Quote

author: NiHaoMike
author_rank: Super Contributor
timestamp: August 16, 2022, 01:50:28 am
content: One could use the PIOs for receive only and mux a standard UART for transmit if the total transmit throughput needed for the muxed group is less than the throughput of one UART. For something like an out of band management controller for a cluster of embedded processors, it would work well.