What is PIO | Programmable I/O on Raspberry Pi Pico
Вставка
- Опубліковано 10 лют 2025
- 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.
Learn more: rptl.io/rp2040-...
Subscribe to our channel: rptl.io/youtube
Looking for kid-friendly projects, educator-led seminars, and information about our non-profit work? Check out the Raspberry Pi Foundation UA-cam channel: rptl.io/rpfyt
BUY A RASPBERRY PI
--------------
Raspberry Pi Pico: rptl.io/pico
Raspberry Pi 4: rptl.io/raspber...
Raspberry Pi 400: rptl.io/400
All Raspberry Pi products: rptl.io/products
Raspberry Pi Store, Cambridge: rptl.io/cambridge
READ OUR BOOKS & MAGAZINES
--------------
The MagPi magazine: rptl.io/themagpi
HackSpace magazine: rptl.io/hackspace
Wireframe magazine: rptl.io/wireframe
Custom PC: rptl.io/custompc
Raspberry Pi Press online store: rptl.io/raspber...
GET HELP WITH YOUR RASPBERRY PI
--------------
Getting started with your Raspberry Pi: rptl.io/getting...
Raspberry Pi Help Guides: rptl.io/help
Raspberry Pi Forums: rptl.io/forums
Technical documentation: rptl.io/techdocs
FOLLOW US
--------------
Twitter: rptl.io/twitter
Instagram: rptl.io/instagram
Facebook: rptl.io/facebook
Raspberry Pi blog: rptl.io/blog
SUPPORT RASPBERRY PI FOUNDATION
--------------
Free coding projects: rptl.io/rpfproj...
Digital Making at Home: rptl.io/dmah
Free online courses: rptl.io/rpfcourses
Raspberry Pi Foundation: rptl.io/rpf
Donate: rptl.io/donate
#RaspberryPi
You guys really nailed it with the PIO on the RP2040. This is cool on so many levels, from introducing the basics of Assembler to a Python user, to solving the timing problems you mention in this video. Looking forward to seeing what comes next!
My grandpappy told me that PIO stands for Pilot Induced Oscillation.
He ain't wrong
I thought it meant : Pigs In Outer-Space .
Parallel Input Output
@@packratswhatif.3990 Not quite, since outer space isn't hyphenated. Try "Pigs In Orbit" instead.
PIO is a great gift to the world. Thank you RPTL.
I made a matrix of 37 x 8 pixels from a single 300 RGB LED strip and used a pi pico to drive it. I mapped the PETSCII font so it can scroll a text that looks like the C64 including all the graphics characters. The micropython program used PIO to push the data to the LEDs with exact timings. I admit I did not write that code myself but it's also pointless trying to re-invent the wheel so I just copied that code. But I can say out of experience that the RP2040 is pretty darn powerful for its price and size. And now you can emulate a C64 with it including a 320x240 display! It uses PIO to exactly time the VGA output signal which is generated on the fly because the Pico does not have enough RAM for a frame buffer.
Would be cool if you shared that code.
Sounds really awesome!
Cool video, and great explanation! I've had issues with checking for button input while executing other code. It's probably mostly due to the fact that I'm not very good at coding, but it will be helpful to learn to use State Machines for things like that. NeoPixels are also a great example, because it's something I add to most of my projects. Looking forward to your future videos!
do you use an irq handler, that works fine for button,
use pull=Pin.PULL_DOWN (the button delivers 3.3v when pressed)
use pull=Pin.PULL_UP ( the button connects to ground when pressed )
import machijne # or from machine import Pin, disable_irq, enable_irq
buttonX=machine.Pin(2, machine.Pin.In, pull=machine.Pin.PULL_DOWN)
buttonX.irq(trigger=machine.Pin.IRQ_RISING, handler=pin_irq)
buttonXwaspressed = False # variable you can check in your main loop, reset it when your code has acted on it.
def pin_irq(pin):
state = machine.disable_irq() # no interrupt while handling this one
# change a variable or act on another pin, if using a variable then
global buttonXwaspressed # essential to use the global already existing variable
buttonXwaspressed = True # let your main loop react to this
machine.Pin(25).value(1) # example, act on hardware, onboard led is turned on.
#end handler with
machine.enable_irq(state) # all irq handlers will act as expected
# you can have the irq handler react to which pinname is given in the parameter,
butn1.irq(trigger=machine.Pin.IRQ_RISING, handler=pin_irq)
butn2.irq(trigger=machine.Pin.IRQ_RISING, handler=pin_irq)
in "def pin_irq(pin)" function
if pin == butn1:
# change or set ... e.g. ON/1/True
elif pin == butn2:
# change or set ... e.g. OFF/0/False or increment (e.g. += 1024)
Very interesting! I'm really enjoying my pico
I have to say I see how PIO is useful but as a beginner I thinks it makes thinks like writing a byte to a port much more complicated than it needs to be. Maybe there is a library that can do this but if so haven’t found it yet. Happy to receive advice if anyone has more knowledge that’s. Best regards Chris
My pico is on the way :)
It can be useful to make a 5V tolerant gpio Pi Pico.
Hi, PIO is present in other Raspberry devices or only in Pico? Thanks in advance
PIO is only for the RP2040 chips. The other RPis use Broadcomm chips, so they do not have PIO
The morse code was SOS?!! Oh no
it was “RASPBERRY PI” sent backwards i p y r r e b p s a r
I wonder, can I make USB port out of those PIO???
Well... yes but why, why would you do that, there is already a micro usb on the pico
@@gamertron0882 My use case is to intercept mouse movement and keys, and make it detect patterns and do stuff - programmable macros for mouse. There are some mouses on the market with functionality like this, but I could use just Pico instead of 50$ mouse + license on their scripting software...
Other people could use it also for hardware keyloggers, or maybe some fancy USB hubs.
Just look into USB signal integrity, USB eye test and abandon the idea.. Even if Pico has enough frequency for USB 1.1 Low speed, which is probably not the case.
You could though poll mouse buttons with your additional MCU like Atmega32u4 and send your macros along the second USB cable or via USB hub IC.
its probably easier to use something like autohotkey or just some python libraries to do that on your computer itself, which is free
@@Mr.Leeroy zou can make bitbang USB on ESP32.... On classical GPIOs....
When is support for arduino ide coming?
Don't ESP32s have PIO? Or is my naivety showing?
The link to more information just results in a 'This Page Can't Be Reached' error...
Eeek. How about now?
@@raspberrypi That now leads to a valid webpage but I can't see anything specifically related to using the PIO - that only seems to be mentioned once, in relation to dithered pixels.
Maybe I misunderstood what was said in the video...
a day later, no problemo, results in "www.raspberrypi.org/documentation/rp2040/getting-started/"
What about using this as a USB joystick?
you could just use the on-board usb-connection for that, reading out a USB-joystick should be pretty easy even without PIO
@@julianbinder2371 someone made usb interface with the PIO for the LULZ
Great video
Morse Code is NOT a series of dots and dashes. It is a series of dits and dahs!
It's pronounced "I squared C," not "I two C." It's actually supposed to be stylized I²C as well, but since that wasn't easily doable in the 80s, I2C was accepted.
Are you sure it's not pronounced "eye eye see"?
on avr it's called: TWI - two wire interface
Actually, I²C is Inter-IntegratedCircuit, or Inter-IC protocol. That's why I is squared.
Programmed I/O is not new. Many generations of Parallel ATA / IDE harddisks used PIO for data handling. The disk's label would state the type of interface and the mode of operation (PIO mode x)
Bought my first ever single board computer (pi zero w)
But keep in mind that an RPi Pico is not a SBC anymore. It's a microcontroller
Why do you always try to advertize for MicroPython in your videos while C++ is also possible with RP2040
It’s the only Internet that you always will be Connected to Wi-Fi and Data with this PIO Thing.
thanks~
Woohoo!
Is this Mark Zuckerberg's voice?
No. The dude sounds irish
can anyone identify another MCU that has a PIO too?
RP2040 is the only one.
If my understanding is correct, this is the same as DMAs in other microcontrollers.
No
DMA is for streaming a chunk of memory to another controller on the board, such as SPI, PWM, and possibly PIO. You could implement SPI or PWM by using PIO if you wanted. Supposedly you can use PIO to generate signals for VGA.
I plan to use PIO for my ws2812 lights so I can construct just the GRB array and have PIO handle generating the signal instead of passing a 16x larger signal array to the SPI controller.
DMA is a way of moving data between memory and other devices, without it going through and occupying the core processor.
Like instructing an intern to move a stack of papers from the filing cabinet to the broom cupboard without having to supervise and micromanage them doing that task.
No sound at all??