Intro to Raspberry Pi Pico and RP2040 - C/C++ Part 3: How to Use PIO | Digi-Key Electronics

preview_player
Показать описание
Programmable Input/Output (PIO) is a unique feature in the RP2040. It allows users to create custom communication peripherals and drivers that run independently of the main program on the CPU. In this video, we’ll show you how to create a simple PIO program that toggles the LED on the Raspberry Pi Pico.

We write a simple blink program in PIO assembly language that toggles the onboard LED and waits for a set number of cycles. We also construct a C helper function in the same PIO file that can be called from the main C program in order to configure the PIO instance and state machine.

In the main C program, we configure the LED pin and set the clock divider for the PIO instance. We then call the helper function found in the PIO program file. We sleep the main CPU so that it does nothing while the PIO program runs independently to toggle the LED.

Product Links:

Related Videos:
Intro to Raspberry Pi Pico and RP2040:

Related Project Links:

Related Articles:

Learn more:
Рекомендации по теме
Комментарии
Автор

Imagine my disappointment when I realized this is the last of the C/C++ series! This was so well done and I learned so much.

trailranger
Автор

Great tutorial. Working on a robotics project. This series was a huge help. Even though it has been two years, I hope to see more.

jonathanlanders
Автор

Thank you! I've been reading a bunch of documentation on the PIO's. And they all seem to leave something out or expect my knowledge on the Pico to be more than it is making me throw my hands in the air and just get frustrated with it. This was a very basic, easily understandable, explanation of the entire concept and how it relates to the CPU clock (which not all docs I've read explain, they just seem to expect you to know that).

larsmuldjord
Автор

Has the "development environment" improved in the past two years? I'm completely new to the pico, but picked one up this week with the idea that I might be able to use it for a project that I had been working on implementing completely in 7400-series logic (if only there were a "DigiKey Prime" for free overnight shipping...). I was able to do the "blink" program on the pico using the Arduino IDE, which was stupidly easy--same exact code compiled and ran, just by changing the build target to the pico--but it's unclear if it's possible to do PIO programming with similar ease in the Arduino IDE.

dmuntz
Автор

think that explanations of PIO, must be with examples that shows the potential of PIO, (like high frequency respond, or fast sampling) because, the clasic blinking looks very complex. Many people could not try to use PIO thanks to this.

rvv
Автор

Jesus Christ, this is one big headache for blinking an LED. Thank you for the video Shawn, enormous work to show us how to do this, but could Raspberry Pi made it more complicate it?

foamyrocks
Автор

Can the pio pins output pwm audio? if so, how can i out put audio in C++ using pio pins? Thanks

pradeepavenkat
Автор

Is this PIO similar to the ULP processor inside the ESP32?
That module has more instructions though, including ADD and SUB math as well as boolean operations like AND, OR, ...
Very useful to execute ADC routines while CPU is asleep.

piconano
Автор

The code compiles, but doesn't blink :/
This PIO thing feels like it would be hell to debug.

tinglin
Автор

This is a needed video. Twi questions. Can the pio be used to implement a toggle buffer of a/d values that a normal interrupt driver does. Second is FreeRtos available much like the dual core ESP32. Thanks

glennedgar
Автор

I have a hard time believing that someone who works for digi-key(assumption) Has never seen a "programmable peripheral" before. Maybe speak with RCN, also of digi-key who has been supporting hardware that's been doing exactly this for 8+ years. You know, the beaglebone white / black ? PRU(programmable real time unit). TI AM355x . . . I'm not saying this isn't a cool feature, but it is definitely not the first. Other than that, great video.

MrYyrkoon
Автор

Didn't the BeagleBone Black have two PRUs (programable real time unit) that would perform similar functionality to the Pi PIOs?

GrahamY
Автор

I wish there was a video detailing how one can use the ws2812 Neopixels in C such that it clearly demonstrates in code how one can individually controll a specific Neopixel in a chain. Say there are 64 NP's, you can put_pixel(urgb_u32(255, 0, 0) and this would set the 0th or 1st NP red however it is not clear how you could make say the 12th pixel red or another color. The examples in the official pico-examples do not do a good job showing how to actually make this work in C at all. There is nothing on the web that really demonstrates this functionality in C.

mytechnotalent