2

Hii I have a big project, and found this when I tried to remove all the test code.

To summarize:

  1. I have a variable that I use as a buffer for string operations called char internalbuffer[32] declared in my file xstrings.h, it is very important and it is used a lot in the other files.
  2. If I call, in Setup, Serial.println(internalbuffer) twice or more, the arduino will run normally.
  3. If I call, in Setup, Serial.println(internalbuffer) once or not at all, the arduino will NOT run any code.
  4. I tried, with no result, referencing in other ways internalbuffer.

You can see the main.cpp file here. (you can check the entire repo here)

My setup:

I've been trying to fix this myself for 2 days now, but got nothing and I'm pretty new to c++ and arduino, any tips or guidance is accepted.

Edit:

What I have tried:

  • Replacing the 2 Serial.println(internalbuffer) to printing any string, didn't work.
  • Instead of the serial prints, add a delay(x), tried from 10ms to 5000ms didn't work either.
  • Removing while(!Serial) seems to have no effect, so I removed it.

New things I've discovered:

  • Moving the serial prints out of the if (rc != OLED_NOT_FOUND) that checks for the oled initialization is not working, so that's new.
  • There is a special place, that if I place the prints there, the arduino keeps calling setup like it was the loop function or something.

I´ve created a pastebin showing these last 2 items more clearly.

6
  • 1
    what happens if you call Serial.println("test123") twice?
    – jsotola
    Commented Jun 1, 2021 at 0:36
  • 1
    try delay(10); instead of the two prints
    – Juraj
    Commented Jun 1, 2021 at 5:00
  • Is there a specific reason you have while (!Serial); at the start of your code? On a nano it should do nothing, but you never know...
    – Majenko
    Commented Jun 1, 2021 at 9:31
  • 1
    Also note that the SSD1306 OLED display takes most of your RAM, leaving you very little to play with. There's a very high chance it's failing to allocate its internal buffer and crashing.
    – Majenko
    Commented Jun 1, 2021 at 9:32
  • jsotola replaced the prints as you suggested, didn't work. Juraj added delay(50) before the 2 jsotola prints, didn't work, removed the jsotola prints and left only the delay(50), also didn't work. Majenko, I've added that while(!Serial) in a desperate moment to fix this problem. Also, I don't think that is, because it runs nice and smooth when the 2 prints with internalbuffer are ran.
    – Qubo
    Commented Jun 1, 2021 at 15:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.