Programming PIO with Pico

Hello,

With support for the new RP2040 MCUs in GitHub - arduino/ArduinoCore-mbed. Is there an example of how to run code using the PIO on the RP2040?

I am trying to get NeoPixels, WS2812, to work using the Pico. Is there a reason that, for instance, the Ardafuit library wouldn't work on the Pico? I cannot seem to make anything happen with the LEDs.

Very Best Regards,
Joachim Haagen Skeie

Hi,

Because an Arduino core for the 2040 was only released very recently, and it is not the official Arduino core, I doubt that anyone has developed examples showing how to use its PIO functions yet.

The timing requirements for ws2812 and similar LEDs is quite demanding and requires some assembler code to be written to achieve it. Assembler code is of course unique to each MCU chip. The libraries available from Adafruit, FastLED will contain the assembler code written for each of the MCU types supported (AVR ATMega, SAMD21 etc). So those libraries would need to be enhanced in order to support the 2040.

Have you tested your strip using an Arduino supported by the Adafruit library, e.g. Uno/Nano?

Hi PaulRB. Arduino's official support for the RP2040 was released just three days ago:

This release split the Arduino Mbed OS Boards platform into three platforms:

  • Arduino Mbed OS Nano Boards
  • Arduino Mbed OS RP2040 Boards
  • Arduino Mbed OS Portenta Boards

These are available for installation via Boards Manager in your IDE and the source code is in the repository.
"Arduino Mbed OS Nano Boards" is for the Nano 33 BLE and Nano RP2040 Connect.
"Arduino Mbed OS RP2040 Boards" is for the Raspberry Pi Pico

However, I think your thoughts about the general support and community knowledge about RP2040 used within the Arduino framework not having had time to accumulate yet are still valid. Fortunately, the RP2040 itself has gotten a lot of attention and even some of the information available that is not specific to Arduino will still be relevant. In addition, Arduino's RP2040 cores are variants of the Mbed OS core that has been out for almost two years now. So most of the information that applies to the Mbed OS core, as well as Mbed OS in general will be relevant.

Thanks, @pert! +1 karma

You're welcome. I'm glad to have the opportunity to spread the news of this significant advancement. Something I think is very notable is Arduino making special effort to provide support for the 3rd party Pico board, even though this is in some ways a competitor to Arduino's own Nano RP2040 Connect product (though the Nano RP2040 Connect is distinctive in having WiFi connectivity).

Anyone interested in the subject of PIO may want to subscribe to this issue report:

That may well receive an authoritative response from the platform developers.

Thank you @pert and @PaulRB for your answers.

On the second topic though. Is there a reason why, for instance, the Adagruit NeoPixel library shouldn't work with a standard "Bit Banging" manner on the Pico? Is there perhaps timing issues that prevent it from working, or something else? Or is the Mbed platform different enough from the standard Atmel platform that the library won't work? (If this is the case, is there a WS2812B library available for Mbed devices that might work, you think?)

kodegenetas:
Is there a reason why, for instance, the Adagruit NeoPixel library shouldn't work with a standard "Bit Banging" manner on the Pico? Is there perhaps timing issues that prevent it from working, or something else?

Yes. I attempted to explain that already. Different assembler code will be needed because it's a different MCU to any other Arduino. OK, some other Arduino have ARM M0 CPU, but the clock speeds of the 2040 are different and the other aspects of the MCU outside the CPU are different, such as how the I/o ports are accessed.

Thank you for your reply @PaulRB.

I found this .py code inside the Pico-examples, which have some ASM code in it, though it looks like it does have requirements for the PIO, still.

There are also a few Python libraries around, like this one pico_python_ws2812b/ws2812b.py at main · benevpi/pico_python_ws2812b · GitHub, but it also seems to rely on the PIO, through call to rp2.asm_pio...

It will be interesting to see how the ArduinoCore integrates the PIO system.

No mention of whether it is compatible with the official "Arduino Mbed OS RP2040 Boards" platform, but here's a post about a port of the Adafruit Neopixels library for RP2040 using the 3rd party Arduino boards platform from Earle Philhower:
https://forum.arduino.cc/index.php?topic=736707

Thank you for your reply @pert! I had a look at it, and it did work with a very small tweak to the source!

That's awesome!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.