Skip to content

Interupts Interfere With WS2812 PIO Implementation #450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
joeRossRobotics opened this issue Feb 18, 2025 · 3 comments
Open

Interupts Interfere With WS2812 PIO Implementation #450

joeRossRobotics opened this issue Feb 18, 2025 · 3 comments

Comments

@joeRossRobotics
Copy link

I'm using the WS2812 driver implementation from the pico-examples repo to control a strip of LEDs. Additionally, my setup includes an MCP2515 CAN controller for communication.

When polling the CAN controller in the main loop, the LED strip behaves as expected. However, when switching to an interrupt-driven approach using the MCP2515's interrupt, the LED strip begins to glitch. While the general animation pattern remains recognizable, it is noticeably distorted.

I suspect this issue may be due to interference between the interrupt routine and the PIO operation for driving the WS2812 LEDs.
Any insights or suggestions would be greatly appreciated!

@lurch
Copy link
Contributor

lurch commented Feb 18, 2025

I think if you actually provided your code, that might give us a better chance to figure out what's going wrong?
Until this is confirmed as an SDK bug, I'll move this issue to pico-feedback.

@lurch lurch transferred this issue from raspberrypi/pico-sdk Feb 18, 2025
@joeRossRobotics
Copy link
Author

So the issue was that the interrupt handling interferes with the precise timing required for the ws2812 protocol. The solution was to disable interrupts while writing to the led strip, and then re-enable them. I'm not sure if this is worth addressing in the example or not?

@lurch
Copy link
Contributor

lurch commented Feb 20, 2025

I guess you could try running the "writing to the led strip" on one core, and the "handling interrupts" on the other core?

I believe the examples in pico-examples are deliberately simple, in order to make them easy to understand. Obviously if they become more "comprehensive", it then becomes harder to see what it is that they're actually trying to demonstrate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants