I chage content string and program hangs/broken.

Hi.

I'm working with a Nano board, a TinyRTC, a OLED display and Arduino IDE 1.8.9.

I have declared two String Pointers Arrays (myStrings and myStringsA ).
When I change some character from that strings and upload code, it doesn`'t works, it is unable to detect Display.

Let me illustrate it. That works fine ( ok... it seems to work) I see on serial monitor logs as I expect, and display show menus an options as I programed, the keyboard and RTC are working weel.

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "RTClib.h"


 //.... some code omited ....//

const char *myStrings[] = {
                     "Ajustar Horas",
                     "Ajustar Minutos",
                     "Ajustar el dia",
                     "Ajustar el mes",
                     "Ajustar el anyo",
                     "Ajustar Linea 1",
                     "Ajustar Linea 2",
                     "Ajustar Linea 3",
                     "Ajustar Linea 4",
                     "Ajustar Prioridad"
                    };

const char *myStringsA[] = {
                     "Ajustar Horas",
                     "Ajustar Minutos",
                     "Ajustar el dia",
                     "Ajustar el mes",
                     "Ajustar el anyo",
                     "Ajustar Linea 1",
                     "Ajustar Linea 2",
                     "Ajustar Linea 3",
                     "Ajustar Linea 4",
                     "Ajustar Prioridad"
                    };

But... this one produce to lcd lib to not detect Display, The only difference is an "X" on de second member of myStringsA :

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "RTClib.h"

 //.... some code omited ....//

const char *myStrings[] = {
                     "Ajustar Horas",
                     "[color=red]Ajustar[/color] Minutos",
                     "Ajustar el dia",
                     "Ajustar el mes",
                     "Ajustar el anyo",
                     "Ajustar Linea 1",
                     "Ajustar Linea 2",
                     "Ajustar Linea 3",
                     "Ajustar Linea 4",
                     "Ajustar Prioridad"
                    };

const char *myStringsA[] = {
                     "Ajustar Horas",
                     "AjustaX Minutos",    // <<------ SEE HERE !! Unbelievable, this X brokes code!!
                     "Ajustar el dia",
                     "Ajustar el mes",
                     "Ajustar el anyo",
                     "Ajustar Linea 1",
                     "Ajustar Linea 2",
                     "Ajustar Linea 3",
                     "Ajustar Linea 4",
                     "Ajustar Prioridad"
                    };

Error is raised by:

 if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }

What is the relationship between the "X" and the LCD library?
It doesn't seem to make much sense. If the error happened later in the code, I might think that I am referencing the pointers badly. But it fails at the beginning !!

It is as if there was a collision between my variable space and that of the LCD library. If so, how could I avoid it?

I have tried several tests, for example:

  • Change the order in which I declare the variables, to check if the problem is that with the pointers I am accessing where I should not.
  • Change the size of myStrings, to check if with smaller declarations, I don't crush other LCD variables.

I'm sure the problem is with my code or because I misunderstand something about programming, but I can't see what it is.

Can I enable more traces of compilation or linking?

Any ideas? someone with a similar problem?

Thank you.

PD: while writing this post it seems that the chip has been fried. Now I can't even program it .... "The programmer is not responding"

My guess is a RAM problem. String constants need RAM at initialization time if not stored in PROGMEM. As you failed to provide the complete sketch, this is just an educated guess.