Board is vanilla Leonardo.
Does anybody came across similar issues? Are any of these libraries are known to do weird things with memory?
P.S.
#include <Pushbutton.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>
#include <TroykaTextLCD.h>
//some static initializers
void setup() {
Serial.begin(9600);
//commented out everything that was there
drawDisplay();
//more code
}
void drawDisplay() {
//commented out all previous operations
Serial.println("Touch the sensor");
delay(100000);
//some code continues
}
void loop() {
//some code that program never really gets to
}
Actually the code after the Serial.print() could be corrupting the serial buffer, by the time you see text in the serial monitor the code is well past that point in the sketch, unless you have a delay() or Serial.flush() to slow things down.
If your text is defined like the above, then I think the text is copied from ROM to RAM before setup. Your code could be stomping on the area of RAM when the text resides after startup.
Thank you for a quick response. I am not sure any external hardware (NFC reader, LCD display, buttons, LEDs etc) can impact the constant string.
As for the software, the disruption apparently happens before the first (after Serial.begin()) line of setup, so only static initializers are executed so far. Placing some of the initializers below:
Yes, something definitely overwrites this character, unless my Arduino caught a kind of evel gremlin I am trying to find what could do this |=0x1D . None of my code is doing such an operation.
Cannot be. I recompiled and restarted many times, glitch is in the same place. I move code around - glitch moves, but stays stable through the recompiles.