What is PIO?

Microcontroller chips, like our own RP2040 on Raspberry Pi Pico, offer hardware support for protocols such as SPI and I2C. This allows them to send and receive data to and from supported peripherals.

But what happens when you want to use unsupported tech, or multiple SPI devices? That’s where Programmable I/O, or PIO, comes in. PIO was developed just for RP2040, and is unique to the chip.

PIO allows you to create additional hardware interfaces, or even new types of interface. If you’ve ever looked at the peripherals on a microcontroller and thought “I need four UARTs and I only have two,” or “I’d like to output DVI video,” or even “I need to communicate with this accursed serial device I found, but there is no hardware support anywhere,” then you will have fun with PIO.

We’ve put together this handy explainer to help you understand PIO and how it can be used to add more devices to your Raspberry Pi Pico.

For more information on PIO and RP2040, check out this article from HackSpace magazine.

23 comments

Avatar

PIO has been around for a while – see https://en.wikipedia.org/wiki/Programmed_input%E2%80%93output

Avatar

Except this kind of PIO has nothing to do with the one from the Wikipedia article. They just use the same acronym.

Avatar

“A while” is decades. I recall having a Z80 PIO chip in my Nascom 2, hmm late 70s perhaps. It was very useful as I recall.

Avatar

@Chinny – I too built a Nascom2 (subsequently expanded up to Z280, using NasBus cards, running CPM). Yes, the Z80 PIO was useful, but that Parallel I/O chip wasn’t anything like the Programmable I/O of the RP2040 – it simply shared the same initials.

Avatar

The PIO on the old micros stood for Peripheral Input / Output. It was a chip that allowed a bussed micro system to input and output bits. In the RP2040 chip it stands for Programmable Input / Output, a totally different thing.

Avatar

Mike, as one of the Mostek Application Engineers dedicated to the Z80 family in the early 80’s, I can assure you PIO stands for “Parallel Input Output”. See http://www.z80.info/zip/z80piomn.pdf

Avatar

Is it possible to create a CAN (Controller Area Network) via PIO?

Avatar

PIO does seems a bit like TPU from 68332, but a lot easier to understand!
I would be nice to have a PIO simulator, that can run PIO code, using also the registers. That allows to step through PIO code. Can show the ouput of each pin in a timing diagram (when there is output) or can take input from some ‘input’ file and send it to the PIO. This would create PIO code more easily and can also help to understand the working of PIO. Makes it more easy to play with it, certainly when a kind of code assembler is integrated (like a python interpreter). Just write some assembler code, compile and execute (should be compatible with the current assembler). Just a idea.

Avatar

> I would be nice to have a PIO simulator, that can run PIO code, using also the registers. That allows to step through PIO code. Can show the ouput of each pin in a timing diagram (when there is output) or can take input from some ‘input’ file and send it to the PIO.
Actually, I am working *exactly* on such a thing. Not yet usable, but stay tuned! :-)

https://github.com/soundpaint/rp2040pio

Avatar

Great!!
I have visit the github and your plans are looking very nice. I am already looking out to use your tool!

Avatar

I was hoping the link in the video would take me to micropython PIO specific, or even PIO specific pages. Instead it takes you to the get started page.

Avatar

To quote: “For more information on PIO and RP2040, check out this article from HackSpace magazine.” Compared to this blog post the HackSpace post linked to might be considered “more information”. But seriously, if I really want to understand what can the RPi 2040 offers, both are in the tabloid class. A useless item list of instructions, without operands and only some arbitrary examples, not even really explaining the SPI demo. Oh well, luckily, your favorite searxh engine will bring up much better and helpful posts than these stopgaps here, such as https://www.cnx-software.com/2021/01/27/a-closer-look-at-raspberry-pi-rp2040-programmable-ios-pio/ with fubctional diagrams, better details, et cetera.

Avatar

Excellent explainer video, a follow on video with a code walk through would be appreciated

Avatar

What is it with saying ” eye two cee”? It is pronounced “eye squared cee”. Lost a lot of credibility there using a voice over that didn’t know how to pronounce it and where was the editorial control?

Avatar

Both are used now, it’s common language due to typing I2C lazyness (and especially if they use I2C naming they are pronouncing it correctly.)

But this is general media, not a technical media.

Avatar

Absolutely no excuse for this.
“But this is general media, not a technical media.”
No it is not it is technical and the least you can do is to use technical language. This mirrors the debate about GPIO identification at the launch of the Pi. Glad to say the right side won on that one.

Eben Upton

I am moderately technical, and I say “eye two cee” much more often than “eye squared cee”.

Avatar

Was that a microphone I heard being dropped? 🤣

Avatar

Then you should know better.

Avatar

TWI? (Ducks and runs!)

Avatar

For what it may be worth, the wiki article https://en.wikipedia.org/wiki/I%C2%B2C originally said i-two-c was incorrect. There was a debate about this starting in 2006. Currently that article says it’s an alternate pronunciation. As a hardware engineer I’ve heard many very experienced people say “i two c” in technical discussions, maybe because it’s faster to say, and everyone still knows what they mean.

Avatar

If you know what it means, what difference does it make how you pronounce it?

Leave a Comment

Comments are closed