RP2040 NeoPixel WITHOUT Pio

Hello!
Does anyone know of a way to use the Adafruit_NeoPixel library for the RP2040, but NOT use the PIO's?
My project already consumes all PIO's for more pressing and timing critical I/Os. The RGBW NeoPixel (while an important) is rarely updated.

Recommendations for other libraries welcome as well.

What do you imagine will communicate a digital signal without using a digital output pin?

Maybe multiplex three, less than critical output pins (for latch, clock, data) and try adding those three pins and the Neopixel on the mux?

Hi xfpd,
Thanks for your reply! This helps me to clarify my question.

The RP2040 . . (specifically) . . has 2 special state machines that have to be programmed in assembly. These state machines can do wicked fast stuff and run independently of either main core. The engineers with Adafruit (when dealing with the RP2040) decided to use these PIOs ( not general digital I/O ) to run the NeoPixel . . well . . because you can get hyper performance that way. The thing is . . that's why I chose the RP2040 . because I needed those PIO's for other things.

So . . that leaves me in search of a library for the RP2040, that uses general I/O like NANO, or other low performance processor would. . . or a way for the Adafruit not to use such a valuable resource.

Again, thank you for reading my question . . and helping me to clarify.
:slight_smile:

Are you saying that you are using both PIO blocks of 4 state machines each or just 2 state machines?

Hello EmilyJane,

I'm using both PIO0 and PIO1.
While I'm not specifically using all the SMs within the (2) PIO's, I am using non-consecutive pins and running at max clock. PIO0 is running function X, and PIO1 is doing something different.
I don't seen any easy way to share.

WS2812 using Assembly...

Hi Xfpd,

I may have to write my own and use this (or something like it) as a template.
The example you linked was assembly code for a different platform so it won't just drop in.
Unfortunately, all of the RP2040 solutions use a PIO (instead of GPIO)
I get it . . the PIO does a fantastic job . . but for many, the RP2040 was chosen for the PIO's to execute high performance functions.
I need to indicate boot / system status . . without using a PIO.

Have you actually tried it? A quick look at the Adafruit library implies that you can select the state machine and the pin you want for the NeoPixel string. You haven't shared any of how you are using the other state machines so it's hard to speculate further.

2 Likes

I have tried. . and I do admit my troubles started with assumptions.

I've used the Adafruit_NeoPixel library many times to effectivity bit bang out the serial comm to the LED's. ( on much lower power processors )
I -ASSUMED- that same behavior when switching to a different processor.

SO FAR, I can get my (2) PIO functions to work . . or NeoPixel + 1 of mine.

That being said, given where I want go in the future, I will continue search for a NEO pixel solution that doesn't burn such a valuable/high power resource.

Thank you all for caring and I wish you smooth trails!

Really? Back when I was tinkering with the RP2040 I used the 2 PIOs with 3 distinct peripherals simultaneously with no issue: a NeoPixel ring, a DHT22 and a DS18B20. It went like this:

Claim an unused state machine on one of the PIOs.
If you can add your program to the PIO, do so.
If not, try the other PIO.
If you can't add your program to this PIO, fail.
Add your program.
Get the default config, set your clock and pins, and initialize and enable the state machine.
Done.

You'll likely run out of PIO program space long before you do state machines. That's been my experience at least.

Hello Van_der_decken

Thanks for your input! I will take a new look at this and hopefully get by for the day.

As a whole, I need to preserve the PIO's for

  • high speed quadrature encoders
  • precision PWM / pulse extenders

not for running a neopixel every once in a while.

Thanks again to you and the whole community.

Since you appear to have made your mind up before posting, I'll just say this in parting; there are 8 state machines across the 2 PIOs. Surely you aren't using all 8 of them.

Thank you for your time.
I appreciate your confidence.

Yes, my original post is accurate. I am seeking a library to run the NeoPixel WITHOUT using the PIO . . ( just like every other processor except the RP2040 )

I also recognize that it can be difficult to separate out experienced engineers vs novices.
In this case, it's a mix. I've been a professional in the robotics field for over 30 years. Granted, most of that has been on the electrical engineering . . which makes me a mix. :slight_smile: Most my software work has been in VHDL / FPGA... not in C/Arduino's

I do wish you well.

Look at FastLED to see if has the options you need.

Maybe your PWM function or some PWM slices can work as a NeoPixel driver.

@chrisbeaty
RP2040 mcu has an 8 SM PIO machines.
Please clarify - are you using a two PIO SM or 8?
If you only use two, why can't you use a third for NeoPixel?

Thank you customcontroller . .

FastLED . . utilizes the PIO ( You can find the PIO.h under src/arm/rp2040/ pio_asm.h
FastLED_NeoPixel . . utilized Adafruits_NeoPixel, which uses the pio also.

It appears the same original solution is being recycled. Part of that makes sense, because, setting all other system demands aside, the PIO is a beautiful way to solve the problem.
When you have a complex system and need that (PIO) hardware for other things, you need to solve NeoPixel communications like you would on a NANO or anything else other than the RP2040.

At this point, I believe we will have to write our own library. It's not the end of the world. I'm just a little surprised that the only solutions (that have been found) use the specialized PIO hardware.

Thank you all for your voices and have a great week!

How many NeoPixels are in your string?

Hi EmilyJame,
There is 1 string of 16 RGBW LEDs.
( Camera ring doubling as system diagnostics / messages during boot up )

I ask because if the number is small, APA102 (DotStar) might be the answer since the cost difference is less troublesome.