Hello,
I'm using a Teensy 3.2 for a project, and it's working great, but I'm having some very bizarre issues -- I suspect the device is somehow running out of RAM. I'm not using all that many libraries -- these are them:
I only have about ~400 lines of my own code, everything is very simple, no large arrays or anything like this. The code will work fine, but when I add even one more function, the serial output is garbage and the device starts behaving very strangely. When I turn on "Optimize code for size", rather than the default "Optimize code for speed" it starts working fine once again.
Here is the start of the serial output before adding an extra function or array. You can see that it looks good....
Here is that same output after putting any new function at any place in my code...Also, when I enable "Smallest size" code optimization, it works normally again with the added function.
It seems like there should be enough RAM:
I'm a little baffled by this problem...with 64K RAM I'd assume I wouldn't be running into these types of issues. It isn't like I'm running a huge ethernet stack on it...
I'm using a Teensy 3.2 for a project, and it's working great, but I'm having some very bizarre issues -- I suspect the device is somehow running out of RAM. I'm not using all that many libraries -- these are them:
Code:
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1305.h>
#include <SD.h>
#include <ADC.h>
#include <Adafruit_MAX31865.h>
#include <TheThingsNetwork.h>
#include <Chrono.h>
#include <TimeLib.h>
#include <EEPROM.h>
#include <ArduinoJson.h>
I only have about ~400 lines of my own code, everything is very simple, no large arrays or anything like this. The code will work fine, but when I add even one more function, the serial output is garbage and the device starts behaving very strangely. When I turn on "Optimize code for size", rather than the default "Optimize code for speed" it starts working fine once again.
Here is the start of the serial output before adding an extra function or array. You can see that it looks good....
Code:
-- JOIN
Model: RN2903
Version: 1.0.3
Sending: mac set deveui 0004A30B0026132E
Sending: mac set adr off
Sending: mac set deveui 0004A30B0026132E
Sending: mac set appeui 70B3D57ED000ACDF
Sending: mac set appkey 105762D2C330C118044E0E23018B085C
Sending: mac save
Sending: mac set ch status 0 off
Sending: mac set ch status 1 off
Sending: mac set ch status 2 off
Sending: mac set ch status 3 off
Sending: mac set ch status 4 off
Sending: mac set ch status 5 off
Sending: mac set ch status 6 off
Sending: mac set ch status 7 off
Sending: mac set ch status 8 on
Sending: mac set ch drrange 8 0 3
Sending: mac set ch status 9 on
Sending: mac set ch drrange 9 0 3
Sending: mac set ch status 10 on
Here is that same output after putting any new function at any place in my code...Also, when I enable "Smallest size" code optimization, it works normally again with the added function.
Code:
-- JOIN
#ðñŠBÃ`xÓBhÁ`Ö›±invalid_param
ü h!Sending: �Göíq*ñ_+*ñA@ò�€*ñ+¾ñÛ²@ò–€+!úþ@ò�€£h A@ò�€*ñ+)Û²@ò‡€+&úñÙ£h 'Øßèð&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& invalid_param
&&&&&&&&&&&&&&&&&&&&&&&&&&&invalid_param
Sending: �Göíq*ñ_+*ñA@ò�€*ñ+¾ñÛ²@ò–€+!úþ@ò�€£h A@ò�€*ñ+)Û²@ò‡€+&úñÙ£h úÑË`ÊxÂç off
&&&&&&&&&&&&&&&&&&&&&&&&&&&invalid_param
Sending: �Göíq*ñ_+*ñA@ò�€*ñ+¾ñÛ²@ò–€+!úþ@ò�€£h A@ò�€*ñ+)Û²@ò‡€+&úñÙ£h 'Øßèð&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& invalid_param
&&&&&&&&&&&&&&&&&&&&&&&&&&&invalid_param
Sending: �Göíq*ñ_+*ñA@ò�€*ñ+¾ñÛ²@ò–€+!úþ@ò�€£h A@ò�€*ñ+)Û²@ò‡€+&úñÙ£h íq*ñ_+*ñA@ò�€*ñ+¾ñÛ²@ò–€+!úþ@ò�€£h 70B3D57ED000ACDF
&&&&&&&&&&&&&&&&&&&&&&&&&&&invalid_param
Sending: �Göíq*ñ_+*ñA@ò�€*ñ+¾ñÛ²@ò–€+!úþ@ò�€£h A@ò�€*ñ+)Û²@ò‡€+&úñÙ£h ¡`pbhxbç:O;hð 105762D2C330C118044E0E23018B085C
&&&&&&&&&&&&&&&&&&&&&&&&&&&invalid_param
Sending: �Göíq*ñ_+*ñA@ò�€*ñ+¾ñÛ²@ò–€+!úþ@ò�€£h £h2Yb`¡`pbhxbç:O;hð
&&&&&&&&&&&&&&&&&&&&&&&&&&&invalid_param
Sending: �Göíq*ñ_+*ñA@ò�€*ñ+¾ñÛ²@ò–€+!úþ@ò�€£h A@ò�€*ñ+)Û²@ò‡€+&úñÙ£h Û²@ò‡€+&úñÙ£h &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 0 off
&&&&&&&&&&&&&&&&&&&&&&&&&&&invalid_param
Sending: �Göíq*ñ_+*ñA@ò�€*ñ+¾ñÛ²@ò–€+!úþ@ò�€£h A@ò�€*ñ+)Û²@ò‡€+&úñÙ£h Û²@ò‡€+&úñÙ£h &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 1 off
&&&&&&&&&&&&&&&&&&&&&&&&&&&invalid_param
Sending: �Göíq*ñ_+*ñA@ò�€*ñ+¾ñÛ²@ò–€+!úþ@ò�€£h A@ò�€*ñ+)Û²@ò‡€+&úñÙ£h Û²@ò‡€+&úñÙ£h &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 2 off
&&&&&&&&&&&&&&&&&&&&&&&&&&&invalid_param
Sending: �Göíq*ñ_+*ñA@ò�€*ñ+¾ñÛ²@ò–€+!úþ@ò�€£h A@ò�€*ñ+)Û²@ò‡€+&úñÙ£h Û²@ò‡€+&úñÙ£h &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 3 off
&&&&&&&&&&&&&&&&&&&&&&&&&&&invalid_param
Sending: �Göíq*ñ_+*ñA@ò�€*ñ+¾ñÛ²@ò–€+!úþ@ò�€£h A@ò�€*ñ+)Û²@ò‡€+&úñÙ£h Û²@ò‡€+&úñÙ£h &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 4 off
&&&&&&&&&&&&&&&&&&&&&&&&&&&invalid_param
Sending: �Göíq*ñ_+*ñA@ò�€*ñ+¾ñÛ²@ò–€+!úþ@ò�€£h A@ò�€*ñ+)Û²@ò‡€+&úñÙ£h Û²@ò‡€+&úñÙ£h &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 5 off
&&&&&&&&&&&&&&&&&&&&&&&&&&&invalid_param
Sending: �Göíq*ñ_+*ñA@ò�€*ñ+¾ñÛ²@ò–€+!úþ@ò�€£h A@ò�€*ñ+)Û²@ò‡€+&úñÙ£h Û²@ò‡€+&úñÙ£h &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 6 off
&&&&&&&&&&&&&&&&&&&&&&&&&&&invalid_param
Sending: �Göíq*ñ_+*ñA@ò�€*ñ+¾ñÛ²@ò–€+!úþ@ò�€£h A@ò�€*ñ+)Û²@ò‡€+&úñÙ£h Û²@ò‡€+&úñÙ£h &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 7 off
&&&&&&&&&&&&&&&&&&&&&&&&&&&invalid_param
It seems like there should be enough RAM:
Code:
Sketch uses 75712 bytes (28%) of program storage space. Maximum is 262144 bytes.
Global variables use 8320 bytes (12%) of dynamic memory, leaving 57216 bytes for local variables. Maximum is 65536 bytes.
I'm a little baffled by this problem...with 64K RAM I'd assume I wouldn't be running into these types of issues. It isn't like I'm running a huge ethernet stack on it...