adafruit/Adafruit_NeoPXL8

Adafruit_NeoPXL8 together with Pico-DMX not working

Closed this issue · 4 comments

Hi,
I try to develop pixel LED driver board controlled by DMX: https://github.com/jostlowe/Pico-DMX
I connected 4 trips to rpi-pico board by this pin alignment: int8_t pins[8] = { 2, 3, 4, 5, -1, -1,-1, -1 };
and starting LEDs: leds.begin(true, pio0)
for start receive DMX this config: dmxInput.begin(13, START_CHANNEL, NUM_CHANNELS,pio1);

Both libraries separately working OK, but together NO, I using different PIO state machines, but i think issue is with DMA because both libraries using DMA.

How to align DMA recourses to use different DMA channels for Adafruit_NeoPXL8?

i find out myself, both libraries using same DMA_IRQ, so i edit DmxInput.cpp file in Pico-DMX:

dma_hw->ints0 = 1u << i;
dma_channel_set_irq0_enabled(_dma_chan, true);
irq_set_exclusive_handler(DMA_IRQ_0, dmxinput_dma_handler);
irq_set_enabled(DMA_IRQ_0, true);

to
dma_hw->ints1 = 1u << i;
dma_channel_set_irq1_enabled(_dma_chan, true);
irq_set_exclusive_handler(DMA_IRQ_1, dmxinput_dma_handler);
irq_set_enabled(DMA_IRQ_1, true);

Thanks for grate library

I trapped into the same issue, finding the same solution independently.
Suggestion:
I don't know whether it is possible to sort of claim an IRQ like for the DMA channels and the PIO state machines.
If not it would be very desirable to add a parameter to the begin method. Which allows to select the IRQ by the application in case of conflicts.
This avoids to edit the library on my own.

Ah! Think I see the trouble. NeoPXL8 is using an “exclusive” IRQ handler whereas it should be using a “shared” handler. I’ll try to make that change this week. Thanks for spotting the issue.

OK, this is fixed in new release 1.2.3; a shared IRQ handler is used, meaning this should play well with other code…providing it too is using a shared IRQ. It looks like Pico-DMX is not doing this at present…but…since they favor IRQ0 (as NeoPXL8 was before), I moved over to IRQ1. So if you restore your version of Pico-DMX to the original code, the two should play well enough together.