Skip to content

Teensy31 stops running APA102 strip #339

Closed

Description

@bryanculbertson

My Teensy 3.1 stops running after a couple minutes of running a single APA102 strip. This always happens after a couple minutes after calling FastLED.show(), but not at exactly the same time on each run. This smells of a memory leak.

In case it matters, I am using data pin 7 and clock pin 14. I have the lastest version of FastLED (4c32e65) downloaded via PlatformIO.

Let me know if you there is other information that would be helpful.

Activity

  1. focalintent commented on Aug 18, 2016

    @focalintent
    Contributor

    Seeing the code you're trying to run would be helpful for attempting to recreate the problem here.

  2. bryanculbertson commented on Aug 18, 2016

    @bryanculbertson
    Author

    It doesn't matter what code is running, as long as it calls FastLED.show() lots of times. I think it crashes sooner the higher NUM_LEDS is, but I didn't measure it it enough times to be sure it wasn't just coincidental.

    #include <FastLED.h>
    
    #define LED_PIN     7
    #define CLOCK_PIN   14
    #define COLOR_ORDER BGR
    #define CHIPSET     APA102
    #define NUM_LEDS    300
    
    #define BRIGHTNESS  200
    
    CRGB leds[NUM_LEDS];
    
    void setup() {
      delay(3000);
    
      FastLED.addLeds<CHIPSET, LED_PIN, CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS);
      FastLED.setBrightness(BRIGHTNESS);
    
      for (int i=0; i<NUM_LEDS; ++i) {
        leds[i] = CRGB::Black;
      }
    }
    
    void loop() {
      for (int i=0; i<NUM_LEDS; ++i) {
        leds[i] = CRGB::Red;
      }
      FastLED.show();
      delay(500);
    
      for (int i=0; i<NUM_LEDS; ++i) {
        leds[i] = CRGB::Green;
      }
      FastLED.show();
      delay(500);
    
      for (int i=0; i<NUM_LEDS; ++i) {
        leds[i] = CRGB::Blue;
      }
      FastLED.show();
      delay(500);
    }
    
  3. reloc4 commented on Aug 19, 2016

    @reloc4

    I have got similar problems with my teensy 3.2. I have found a workaround by disabling USB. ( Setting usb Type to " no USB" in the Menu. )
    Disconnecting USB seems to help too, but eventually the Program stoops as well.

  4. marmilicious commented on Aug 23, 2016

    @marmilicious
    Contributor

    I'm experiencing something similar with things "locking up" so I thought I'd share what I'm seeing here too. I'm using a Teensy 3.0 and LPD8806 strip (32 pixels). This was also happening for me with an APA102 strip (38 pixels). This evening was testing with a slightly modified version of the FastLED cylon example, http://pastebin.com/wRX2U00B but this "locking up" happens to me with other sketches also.

    I did some tests experimenting with how often FastLED.show() is called and it seemed like things would "lock up" sooner when it was called very often. But it's not consistent for me as to how quickly it locks up. For example if I call show() every 15 milliseconds it might lockup after 20 seconds, or it might run for several minutes. If there wasn't any delay at all though, and show() was called every single loop, then things would usually just stop running immediately right after sketch upload. I could watch the Teensy's onboard led blink from the update, then maybe the first few pixels might light up, and then it would be locked up.

    After I upload a sketch and it locks up, if I unplug the MCU from the computer and just power it with a battery it seems to run fine without ever "locking up". I also tried reloc4's suggestion of setting USB type to "no USB" and that seemed to work fine (but I didn't let it run for a really long time).

    I don't think I ever experienced this "locking up" in the past with Arduino IDE 1.6.8, but I think this was happening with 1.6.9. Can't remember if I ever tried out 1.6.10. Currently I have the new 1.6.11 installed and am testing out Teensyduino 1.30 beta2.

  5. focalintent commented on Aug 23, 2016

    @focalintent
    Contributor

    Hmmm - I wonder if there's some conflict happening between the USB peripheral and the SPI peripheral? Out of curiosity - what happens if you put #define FASTLED_FORCE_SOFTWARE_SPI 1 before the #include <FastLED.h>?

    If the USB peripheral is leaving one of the status registers that are being checked by the SPI code in a weird state (or, if I'm checking the SPI status register incorrectly) that could cause things to lock up.

  6. marmilicious commented on Aug 23, 2016

    @marmilicious
    Contributor

    Adding #define FASTLED_FORCE_SOFTWARE_SPI 1 above the FastLED.h include does seem to fix the locking up, but (unexpectedly!) it also made all the pixels display as nearly white (as if saturation was set to a very low value).

  7. focalintent commented on Aug 23, 2016

    @focalintent
    Contributor

    Huh - that's a particularly strange reaction - what types of LEDs are you driving? (If they're something like WS2801's, the software SPI on the teensy 3.x may be driving things too fast!)

  8. focalintent commented on Aug 23, 2016

    @focalintent
    Contributor

    (Also, it feels like a thing that happens when clock/data pins are backwards)

  9. marmilicious commented on Aug 23, 2016

    @marmilicious
    Contributor

    My setups use Data on pin 11, and Clock on 13. Haven't changed anything there.

    With Teensy 3.0 and LPD8806 all pixels went nearly white with FASTLED_FORCE_SOFTWARE_SPI 1. Without force software spi colors are correct, but then getting the lockup.

    Just tried that same Teensy 3.0 with an APA102 strip and that is running fine color wise and not locking up when using FASTLED_FORCE_SOFTWARE_SPI 1 (and powered via the USB from computer).

    And now I tested with a different Teensy 3.0 and a different LPD8806 strip (32 pixels) on a different USB plug (thus a different COM port) and it locks up without the FASTLED_FORCE_SOFTWARE_SPI 1. If I add force software spi it's not locking up, but I do see odd flickering, even more so in the first few pixels. I just tried unplugged the USB and powering it with wall power supply and still seeing some odd flickering in some pixels. So that doesn't seem like it's USB related then. Meh, this is totally confusing me.

    I'm going to uninstall arduino IDE and go back to 1.6.8 again. Thank you for your help and suggestions Daniel.

  10. focalintent commented on Aug 23, 2016

    @focalintent
    Contributor

    (Also - make sure that you are not using the FastLED version that comes w/teensyduino - I've done a bunch of fixes since then)

  11. marmilicious commented on Aug 23, 2016

    @marmilicious
    Contributor

    Yes, I never install FastLED that way, always grab the the latest here at github. :)

  12. dimitre commented on Aug 28, 2016

    @dimitre

    I'm using Teensy 3.2 and APA102 and have freezing issues too, both with Teensyduino and Github latest version. It seems to be USB related because it runs well on separate 5V font.
    It takes almost the same number of FastLED.show() calls to freeze, I suppose it is about 2200 calls.

    this is the minimal code to reproduce here:

    #include "FastLED.h"
    #define NUM_LEDS 80
    #define DATA_PIN 7
    #define CLOCK_PIN 14
    CRGB leds[NUM_LEDS];
    
    void setup() {
      LEDS.addLeds<APA102, DATA_PIN,  CLOCK_PIN, BGR>(leds, NUM_LEDS);
      LEDS.setBrightness(65); //100
    }
    
    void loop()
    {
      float r =  sin(millis() / 30.0) * 127.0 + 127;
      for (int a = 0; a < NUM_LEDS; a++) {
        leds[a] = CRGB(0, r, 255 - r);
      }
      FastLED.show();
    }

    Thanks

  13. reloc4 commented on Aug 28, 2016

    @reloc4

    Seems like you don't need to change the colour at all and the number of calls till the freeze is different every time. I have measured 176 to up to 5700 calls with is code:

    #include "FastLED.h"
    #define NUM_LEDS 144
    CRGB leds[NUM_LEDS];
    
    void setup() {
      delay(2000);
      FastLED.addLeds<APA102, BGR>(leds, NUM_LEDS);
      pinMode(7, OUTPUT);
      digitalWrite(7, HIGH);
      FastLED.setBrightness(2.55 * 1.0); // 1% Helligkeit
      FastLED.setMaxPowerInVoltsAndMilliamps(5,2000); 
      Serial.begin(9600);
    }
    
    void loop()
    {
          FastLED.show();
          static long d = 0;
          d++;
          Serial.println(d);
          //delay(5);
    }
    
  14. marmilicious commented on Aug 28, 2016

    @marmilicious
    Contributor

    Just to follow up, I reverted back to using Arduino IDE 1.6.8 and Teensyduino 1.28 (which I don't believe I ever had any troubles with in the past) but I'm still getting the locking up.
    Since the locking up only happens when the controller is plugged into USB, I wondered if something had gone wacky with my USB drivers, so I uninstalled all USB drivers, but still no luck solving this. I'm not sure how to continue to try to figure this out, or what to test?

  15. reloc4 commented on Aug 28, 2016

    @reloc4

    I just reverted back to fast LED Version "12 Apr " now I have got no freeze.

    I'm have narrowed it down :

    21 Apr no frezze
    22 May no frezze
    8 Jun frezze
    4 Jun no frezze
    7 Jun frezze

    seems to be commit 4a71eea from 7 Jun

    guess we are stuck in this loop:

        // Wait for the last byte to get shifted into the register
    +       while( (SPIX.SR & 0xF000) > 0) {
    +           // reset the TCF flag
    +           SPIX.SR |= SPI_SR_TCF;
    +       }
    

    Yes I just confirmed this by undoing the commit 4a71eea in the current master. Issue resolved.
    ( I don't actually understand what's happening there)

  16. 9 remaining items

  17. reloc4 commented on Aug 30, 2016

    @reloc4

    I was using using IDE 1.6.8 and Teenysduino 1.29 if there is anything else to try I can give it a shot.

  18. hydronics2 commented on Aug 31, 2016

    @hydronics2

    I uploaded using the 339 branch above. I'm using Arduino 1.69, Teensyduino 1.29 and Teensy3.2 and working fine for a couple of hours now.

    I'm running 4 strips of about 600 APA102 pixels in SPI mode using an assortment of hardware SPI pins (7,11,13,14) without freezing. thanks!

  19. PaulStoffregen commented on Sep 5, 2016

    @PaulStoffregen
    Contributor

    I'm preparing to post Teensyduino 1.30-beta4, and (hopefully very soon) turn this into a stable 1.30 release.

    I've pulled in the 339 branch for 1.30-beta4. Please let me know if this is ok for a final 1.30 release? Would be nice to have a good, updated FastLED with the installer.

  20. hydronics2 commented on Sep 6, 2016

    @hydronics2

    still working well for me.

    I'm having to run the teensy at 16mhz to eliminate flickering but I'm
    guessing that's an unrelated issue(?).

    On Mon, Sep 5, 2016 at 1:28 PM, Paul Stoffregen [email protected]
    wrote:

    I'm preparing to post Teensyduino 1.30-beta4, and (hopefully very soon)
    turn this into a stable 1.30 release.

    I've pulled in the 339 branch for 1.30-beta4. Please let me know if this
    is ok for a final 1.30 release. Would be nice to have a good, updated
    FastLED with the installer.

    —
    You are receiving this because you commented.
    Reply to this email directly, view it on GitHub
    #339 (comment),
    or mute the thread
    https://github.com/notifications/unsubscribe-auth/ADbHPKRhoWUDdzXZFpW1zcLr4EV23O-Aks5qnHtpgaJpZM4JnN81
    .

  21. dimitre commented on Sep 7, 2016

    @dimitre

    I can confirm APA102, Teensy 3.2 running OK with Teensyduino 1.30 final (339 branch)

  22. added a commit that references this issue on Sep 13, 2016
  23. jhps commented on Nov 30, 2016

    @jhps

    Also having this problem on a APA102s on Teensy 3.1, with Teensyduino 1.31 and also with FastLED d99001d, but not with b01f941 as per https://forum.pjrc.com/threads/35684-FastLED-freezing-with-prop-shield.

  24. jhps commented on Dec 4, 2016

    @jhps

    More or less undoing fe32cf1 "attempt a fix for #339 - guard waitfully against a race condition ..." seems to fix it for me. I do not know what the theory of that commit was, or how to test the problem it addressed.

  25. Karniv4 commented on Dec 5, 2016

    @Karniv4

    No real help here, just confirming removing the fix solved the hanging problem for me. Raspberry Pi 3 pushing tpm2 to the Teensy 3.2 over usb serial (Using Pixelcontroller : 720 x apa102's)

  26. Plasmarobo commented on Jan 27, 2017

    @Plasmarobo

    I'm definitely having this issue with master driving APA102s via SPI with a Teensy 3.2.
    b01f941 corrects it for me, but none of the other attempts at fixes do.
    My USB is still in serial mode, and has no effect on the issue either way.
    I am also read a lot of data over I2C as well. Other commits seem to destabilize the I2C hardware (sometimes I2C locks up, sometimes SPI locks up).

  27. florianlink commented on May 14, 2017

    @florianlink

    The current master branch fixes my hangs that I experienced with FastLED + FFT + Serial1 on Teensy 3.2, see the bug mentioned above!

  28. PaulStoffregen commented on May 15, 2017

    @PaulStoffregen
    Contributor

    see the bug mentioned above!

    Could you please be more specific. I do not see any code above using Serial1. Did I miss it?

    In fact, when I text search this page, your message is the only occurrence of "Serial1" my browser can find.

    Just so you know, I ignore any bug report which does not have a complete program I can copy into Arduino and run on a board.

  29. florianlink commented on May 15, 2017

    @florianlink

    It was not a bug report, I just said, that

    #419

    fixes the problems described in this bug, so I think this bug can be closed.
    Before trying the current master of FastLED, I also tried your 339 fix-branch and it did not fix my hangs.
    But the current master, which includes the fix for 419 fixes the hangs.

  30. hydronics2 commented on Jun 23, 2017

    @hydronics2

    The current version of Teensyduino 1.37 that includes a newer version of FastLed works for me..! No locking up.

    I have 600+ APA102 LEDs and I still have to run the LEDs at DATA_RATE_MHZ(12) and run the teensy at 16MHZ to completely remove the flickering.

    FastLED.addLeds<LED_TYPE,DATA_PIN1,CLOCK_PIN1,COLOR_ORDER, DATA_RATE_MHZ(12)>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions