HopWorks
Active member
Hi Everybody,
Sorry for the long-winded post. I wanted to include all the details because I need to know if there is an explanation for all of this.
I am not a C or C++ guru or I would probably be able to answer this, but I am seeing some strange behavior and it is shaking my confidence in the absolution of C++ programming. Worse, I am worried I have a bad teensy 3.1 (black board) and these things are signs of subtle issues.
I had a sketch that controlled WS2812 lights using the OctoWS2811 library and it worked very well. I did some great effects and controlled serial communications using interrupts and everything was great. Because I planned to use a few WS2812 LED modules as status indicators for my next project, I left all the code in and built around it. As a new sketch of course. Things got pretty big, but I was still WAY below my memory and flash limits (52k of 256k flash, 4.4k of 64k ram). Then I added a few global variables. Nothing fancy, just a few INT's. Now my program would run for exactly 11 flashes of the board's LED (via intervalTimer) and then went solid and crashed. I repeated the issue several times, and the LED always flashed 11 times, so I knew it was a software issue. I took those global variables back out, and the sketch worked fine. How is it that I declare a few global variables, and not even use them, and that causes a crash?
I figured it was a memory issue, especially since OctoWS2811 uses DMAMEM which I do not fully understand, so I removed everything related to the LED project, added back those few global variables, and all was good again.
Until now. Another anomaly! I created a global variable as 'int armed=false;'. I later used it in an IF, as in 'if(armed=false) Serial1.print("disabled"); else Serial.print("ENABLED"); and the result was 'ENABLED'!!! That would mean that 'armed' is set to true, but I searched my code and NOWHERE is it used except in the above line of code. So, thinking maybe I used a keyword as the variable's name, I changed it to 'system_armed' and now it works as expected, outputting 'disabled'. My question is... WHY???
I have rebooted my windows system, cycled all my project's power, and yet the behavior persists.
Do I have something to worry about?
I haven't posted code yet. I am going to do a simple sketch and see if I can duplicate it. I haven't tried any of my new green board teensy 3.1 units yet. That's next.
Thank you for your time!
Sorry for the long-winded post. I wanted to include all the details because I need to know if there is an explanation for all of this.
I am not a C or C++ guru or I would probably be able to answer this, but I am seeing some strange behavior and it is shaking my confidence in the absolution of C++ programming. Worse, I am worried I have a bad teensy 3.1 (black board) and these things are signs of subtle issues.
I had a sketch that controlled WS2812 lights using the OctoWS2811 library and it worked very well. I did some great effects and controlled serial communications using interrupts and everything was great. Because I planned to use a few WS2812 LED modules as status indicators for my next project, I left all the code in and built around it. As a new sketch of course. Things got pretty big, but I was still WAY below my memory and flash limits (52k of 256k flash, 4.4k of 64k ram). Then I added a few global variables. Nothing fancy, just a few INT's. Now my program would run for exactly 11 flashes of the board's LED (via intervalTimer) and then went solid and crashed. I repeated the issue several times, and the LED always flashed 11 times, so I knew it was a software issue. I took those global variables back out, and the sketch worked fine. How is it that I declare a few global variables, and not even use them, and that causes a crash?
I figured it was a memory issue, especially since OctoWS2811 uses DMAMEM which I do not fully understand, so I removed everything related to the LED project, added back those few global variables, and all was good again.
Until now. Another anomaly! I created a global variable as 'int armed=false;'. I later used it in an IF, as in 'if(armed=false) Serial1.print("disabled"); else Serial.print("ENABLED"); and the result was 'ENABLED'!!! That would mean that 'armed' is set to true, but I searched my code and NOWHERE is it used except in the above line of code. So, thinking maybe I used a keyword as the variable's name, I changed it to 'system_armed' and now it works as expected, outputting 'disabled'. My question is... WHY???
I have rebooted my windows system, cycled all my project's power, and yet the behavior persists.
Do I have something to worry about?
I haven't posted code yet. I am going to do a simple sketch and see if I can duplicate it. I haven't tried any of my new green board teensy 3.1 units yet. That's next.
Thank you for your time!