Constant string in the middle of a program changed

Seems bit three is being flipped.

"u" is 117 = 0111 0101
"}" is 125 = 0111 1101

I tried different characters instead of "u". Apparently what happens is
*pointer_to_this_byte_in_memory |= 0x1D

See post #11

I will try a different LCD, thank you

I thought that you said that the issue was with Serial print independent from the lcd?

I came across this issue when printed this string on LCD. It persisted when I printed it to Serial instead.

Don't see anything obvious, like an out-out-bounds array access.
Could be memory problems, I'm not familiar with the mit_core, TroykaTextLCD, or Adafruit_PN532 libraries. Generally the type of problem you are having is caused by something writing past the end of an array.

You can use the F() macro to put the text strings in flash memory, that would save some ram memory and keep anything from changing the text, but it would not necessarily fix the problem, just move it to somewhere else.

As an example,

  Serial.println("Starting NFC setup..."); //stores text in ram
  Serial.println(F("Starting NFC setup...")); //stores text in flash memory

Thank you

but it would not necessarily fix the problem, just move it to somewhere else
This is exactly my issue. Changed character is not a big deal, but if it hits something useful next time, the program will malfunction.

Is there any good simulator that I can use to track down what changes memory?

Do you have another Leonardo you can try? There certainly can be a defective bit somewhere in the memory.

I deployed my sketch on wokwi.
What I get is:
"Touch the reaรตer"
Few symbols off, but the same issue. Clearly it is software!!

Not "clearly"... only you had access to the hardware and software. Now that you made the issue migrate, start removing excess devices and code to find the minimum sketch needed to (1) make it break and (2) the minimum sketch needed to make it work.

You still have not posted a wiring diagram... so "not clearly."

Sorry I am not good at drawing, not even sure which tools to use.

  1. LCD display on the I2C
  2. NFC reader on the I2C + IRQ 12 on the digital pin
  3. 3 buttons on the digital pins 4-6
  4. Buzzer on the pin 10
  5. IR LED on the pin 11

Well, my issue is, as soon as I move around big chunks of code, the issue migrates from this string and I am not sure it disappeared completely or simply migrated. Anyway, I will try, thanks for a tip.

Paper and pencil will be fine. Try to use parallel lines for wires (too many crossing lines are confusing). I am sure you will do fine... at least give it a try.

Help me please understand how this can help anybody if issue reproduces on a simulator without anything but the arduino board?

I could stare at one of my problems for hours, "knowing" I have been thorough. You could give a brief glance at my problem and see "it" without knowing, but making me realize my mind was selectively dismissing "that." You might hear it as "a second set of eyes" or on the other end "fingerprint troubleshooting" (considered the worst - when you do things because "someone else did"). It's the bystander that can see the facts without favor, when those involved can not separate it. It's not against you. We have all been to that point. My suggestion seems tangential at best. It's the Trinity: sketch, drawing, description (with datasheets for added support). You will be happy with the results. Hopefully, a good conclusion, but "results" could also mean a bad conclusion. Either way, the trinity will get you there faster.

Sure. It looks like that. All my devices are small shield and I use 3-wire flat cable to connect them to my connectivity shield that sits on top of the Arduino Leonardo.

Can you please post the link to the wokwi instance which has the code and demonstrates the issue/

Sure! testMy Memory Issue - Wokwi ESP32, STM32, Arduino Simulator

Change the order of these two... what do you get?

      lcd.print("Touch the reader2");
      Serial.println("Touch the reader1"); //THIS ONE

It was not the order, it was the extra "1" character. Keep the order...

Both... change order and add extra character.

Now... to find why this happens... timeout? overflow? memory?

      lcd.print("Touch the reader");
      lcd.setCursor(0,1);
      Serial.println("Touch the reader."); //THIS ONE

Yields:

Touch the reader.
Starting NFC setup...
Didn't find RFID/NFC readerSetting UI mode to 0
Touch the reader.