adafruit / Adafruit_nRF52_Arduino

Adafruit code for the Nordic nRF52 BLE SoC on Arduino
Other
601 stars 489 forks source link

[Solved] FastLED Crashing #770

Closed someburner closed 1 year ago

someburner commented 1 year ago

Operating System

Problem

literally any FastLED.show() call crashes almost immediately. Remove FastLED, or just dont' call show() and application runs perfectly.

It appears to be occuring somewhere inside here in clockless_arm_nrf52.h. Reason I'm making an issue here is just to see if other people with Adafruit nRF52 hardware are experiencing the same thing. And Also because I believe it may be due to FastLED PWM not playing nicely with Adafruit nRF arduino.

    FASTLED_NRF52_INLINE_ATTRIBUTE static void startPwmPlayback(uint16_t bytesToSend) {
        PWM_Arbiter<FASTLED_NRF52_PWM_ID>::acquire(isr_handler);
        NRF_PWM_Type * pwm = PWM_Arbiter<FASTLED_NRF52_PWM_ID>::getPWM();

        // mark the sequence as being in-use
        __sync_fetch_and_or(&s_SequenceBufferInUse, 1);

        startPwmPlayback_InitializePinState();
        startPwmPlayback_InitializePwmInstance(pwm);
        startPwmPlayback_ConfigurePwmSequence(pwm);
        startPwmPlayback_EnableInterruptsAndShortcuts(pwm);
        startPwmPlayback_StartTask(pwm);
        return;
    }

Should be quite easy to reproduce if anyone can give it a shot just to make sure it's not just me.

hathach commented 1 year ago

As far as I know It is implemented already https://github.com/adafruit/Adafruit_nRF52_Arduino/issues/109. Please try to ask or file an issue on fastLED since they know their code better. You could open an issue with specific changes request if it is narrow downed to be the specific issue of this core PWM implemenation.

someburner commented 1 year ago

Sounds good. I just thought you guys might have some ideas since FastLED doesn't seem very active and this would be a nice benefit for those of us that enjoy purchasing adafruit hardware. Neopixel works so I just am thinking there are some tricks that need to be applied to FastLED or maybe a more recent nordic toolchain broke something.

hathach commented 1 year ago

we would like to help but not familliar with FastLED codebase and usage. I am sure there is other user running it on nrf52 in the FastLED dicussion/forum. Once posted in FastLed repo, you could link to this issue, I will also try to follow to see if there is anything I could help there.

someburner commented 1 year ago

@hathach

Submitted an issue over there. I agree that is the best place for it, but I am wondering if you (or anyone looking?) could simply give it a try yourself with latest Adafruit_nRF52_Arduino and latest FastLED just so I can figure out if this is easy for others to reproduce, or if I'm just missing something stupid.

For me the issue is very easy to reproduce, just hook up a WS2812B strip of any length (mine is 64 leds, but doesnt seem to matter), call the FastLED setup code, do FastLED.show(), and see if it locks up.

someburner commented 1 year ago

Turns out it was due to platformio optimizing out the ISR handler. -_-

hathach commented 1 year ago

ah great, thank you for your update. I am sure someone with same issue will find this info helpful. Yeah, platformio can do more optimization and neat trick that is why I usually ask people to double check with Arduino IDE and then try to compare with Arduino first.