Author Topic: 8 UARTs using asm_pio / PIO / DMA / Micropython on the rPI Pico  (Read 913 times)

0 Members and 1 Guest are viewing this topic.

Offline spostma

  • Regular Contributor
  • *
  • Posts: 63
  • Country: nl
just a link to another interesting rPi Pico project to bit-bang 8 UARTs
using the PIO state machine coprocessor (German site):

https://www.mikrocontroller.net/topic/540256

I think that one could extend this to 32 UARTS using 4 PIOs if needed to make massive serial port server!  :)
 
The following users thanked this post: voltsandjolts, pcprogrammer


Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 2349
  • Country: nl
Re: 8 UARTs using asm_pio / PIO / DMA / Micropython on the rPI Pico
« Reply #2 on: August 13, 2022, 07:36:29 am »
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.

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3898
  • Country: us
Re: 8 UARTs using asm_pio / PIO / DMA / Micropython on the rPI Pico
« Reply #3 on: August 13, 2022, 08:37:38 pm »
Quote
I think that one could extend this to 32 UARTS using 4 PIOs
  • There 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...)
 

Offline mino-fm

  • Regular Contributor
  • *
  • Posts: 107
  • Country: de
Re: 8 UARTs using asm_pio / PIO / DMA / Micropython on the rPI Pico
« Reply #4 on: August 14, 2022, 07:26:22 am »
So it's eight half-uarts, rather than 8 full uarts,

That's right.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3898
  • Country: us
Re: 8 UARTs using asm_pio / PIO / DMA / Micropython on the rPI Pico
« Reply #5 on: August 14, 2022, 07:48:30 am »
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.
 

Offline spostma

  • Regular Contributor
  • *
  • Posts: 63
  • Country: nl
Re: 8 UARTs using asm_pio / PIO / DMA / Micropython on the rPI Pico
« Reply #6 on: August 15, 2022, 03:25:36 pm »
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 use two PIO 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 machines for 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.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3898
  • Country: us
Re: 8 UARTs using asm_pio / PIO / DMA / Micropython on the rPI Pico
« Reply #7 on: August 16, 2022, 01:42:01 am »
Quote
so 8 channels would use two PIO units:
Two "state machines."
 
Quote
However, https://www.raspberrypi.com/products/rp2040/specifications/ states the RP2040 PIO specs:
'8 × Programmable I/O (PIO) state machines for custom peripheral support'
You're confusing "PIO Units" with "PIO State machines."  The data sheet  (Section 3.1: PIO Overview) says:
 
Quote
Figure 38. PIO block- level diagram. There are two PIO blocks with four state machines each. The four state machines simultaneously execute programs from a shared instruction memory. FIFO data queues buffer data transferred between PIO and the system. GPIO mapping logic allows each state machine to observe and manipulate up to 30 GPIOs.
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 8399
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: 8 UARTs using asm_pio / PIO / DMA / Micropython on the rPI Pico
« Reply #8 on: August 16, 2022, 01:50:28 am »
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.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf