Program stops after FastLED.show();
I’m suddenly facing an issue where my program running on a Teensy 3.2 stops when it reaches a FastLED.show();
I know this because I moved a serial print through my code, and my print does not get output to the console as soon as I move it after the first occurrence of FastLED.show();
I have some other programs that run fine on the same Teensy.
I haven’t used this particular program since last summer, and I have done absolutely no changes since then. So I’m thinking it might be broken after a library update maybe? The program compiles just fine, so I have no error messages to work with.
See the attached link for my code.
- The program enters setup() (line 666)
- Runs down to and enters Ledstrip.BloomingRainbow(); (line 676)
- Then stops at FastLED.show(); (line 522)
(This line is commented out in my code right now, but it’s usually not)
https://pastebin.com/LDQiyqa8
Some additional info: I’ve tried several different versions of FastLED. Same problem with both 3.1.6, 3.1.3, and 3.1.0
I’d start with don’t call FastLED.show or things that call FastLED.show in setup, it’s generally a bad idea for a variety of reasons - but I also think that it’s extra bad with the OctoWS2811 driver. It’s one of those things where most of the time it works fine without any problems, and then sometimes things go weird (especially if other parts of the system get updated - e.g. things around clocks, timers, watchdogs, etc…)
@Daniel_Garcia Aha, I didn’t know that.
But I’ve removed all instances of FastLED.show() that was called during setup, and still it stops at the first instance of it that the program encounters.
Digging a little deeper, I can see that the program stops when it reaches “pCur->showLeds(scale);” in the function “void CFastLED::show(uint8_t scale)” in FastLED.cpp
I’ve been deleting more and more parts of my code now, and found that when I delete some for-loops that create an array with the correct LED-order for my setup, the program doesn’t stop anymore.
I really don’t see why this part of my code would make anything stop, but that’s what I’m seeing.
The part in question is line 337 to 352. But the even stranger part is that the program starts running again when I delete either both the first two for loops in this section, or the two last ones. (Or all of them).
I’m unable to see any logical reason for this 
https://pastebin.com/VUNMWG5v
It sounds like a memory problem then, or a memory corruption problem.
One possible thing to look at - you’ve got a lot of wasted memory in there - for example your arrays blomst1Omriss, blomst1Hull, blomst2Omriss, blomst2Hull together use over 26k - or 40% of the available memory - and you aren’t even using much of it.
Then the leds array uses another 4872 bytes. Then your LedsMultiTask object itself is using about 6500 bytes. And you have about another 1k used in random arrays and values, which brings you up to about 40KB used.
Then, the OctoWS2811 driver in FastLED is going to malloc another ~10k of bytes (for draw/rendering buffers used by OctoWS2811 under the hood). I’m wondering if the memory allocator is giving you back memory that’s overlapping with your giant arrays - and then when you write into the giant arrays you’re writing into memory that may be getting used by the OctoWS2811 driver itself, breaking things and causing everything to lock up? (Also the system needs memory space available for things like function call stack and so on and so forth).
It’s possible that you have a math error in your LedArrayMaker function that’s causing you to write outside of the arrays which would also cause weird things to happen, but a quick check of your math in there didn’t bring up anything obvious.
I deleted one of my LED-modes, and could then delete two of my big arrays. Then the program started running again, so I think you where correct about overlapping memory.
Thank you very much for the fast reply. I was a bit stressed about this because I was going to use this program for a LED installation at a festival. I had not planned on debugging my code before the festival!