Closed Riffer closed 1 year ago
This is a problem in the library/your code. NeoPixelConnect hard stomps on the PIO configurations without using the SDK to allocate it. It overwrites the PIO in use by the SerialPIO while it's running, leading to boom. The library should use the allocation functions from the SDK instead of hardcoding PIO 0/SM 0 as default.
Thank you for the fast answer and the hint. I wrote I had already tested other NeoPixel libraries, but that was in another source code where FreeRTOS was involved.
For my simple example above, now, with the Adafruit NeoPixel library, SerialPIO works together with NeoPixel without a problem.
I will now narrow down the issue with FreeRTOS. I observed that SerialIO, NeoPixel and FreeRTOS don't work simultaneously. Even without NeoPixel, SerialPIO as an RX at 115200 seems to jitter as soon as FreeRTOS is involved and maybe I must switch to a real UART. Do you know if "Serial" (for debug output) can be used independently from UART0?
Because the hardware from WaveShare has only NeoPixel onboard, I want to use it instead of the standard LEDs in my project.
I built a minimal example to demonstrate the problem
As long as the begin() for the SerialPIO is commented, the pixel works and the loop() puts a 0 to serial. To check whether the device hangs, I added setup1() and loop1(), which puts out a 1 to serial.
setup() and setup1() exit putting "exit setup" successfully in every case.
Without begin() for SerialPIO, the output is simply 1 and 0 alternating. With begin(), you will only see 1 - loop() does not work any longer while loop1() still works.
To ensure this is not a problem with the library NeoPixelConnect I already tried different ones from Adafruit and so on with the same result (I guess under the hood, they work all the same, but I am not able to understand the internals for the RP2040).
The same problem may or may not exist for the ItsyBitsyRP2040 - I took (and modified) the code from here: #756