Explain this: EEPROM Hex dump, missing bytes (solved)

I wrote a program to dump the contents of the EEPROM (am I reinventing the wheel…again) ?
Works well except for one thing … there are locations that seem to be missing ???

/* Program: EEPROM Dump 
   This program prints the contents of the EEPROM in HEX */
        
#include <EEPROM.h>
unsigned long addr;
byte i;

void setup()
{ Serial.begin(9600);
  do
  { 
    /* ------ Print the address padded with spaces ------ */
    Serial.println("");
    if (addr<1000) {Serial.print(" ");}
    if (addr<100) {Serial.print(" ");}
    if (addr<10) {Serial.print(" ");}
    Serial.print (addr, DEC);
    Serial.print ("  ");
    /*------- Print the Hex Values in groups of 16 ---------*/
    for (i=0; i<16; ++i) 
      {
       Serial.print (EEPROM.read(addr), HEX);
       ++addr;
      }
  } while (addr < E2END);   // E2END is the end of the EEPROM
  // used to check ending address 
  // Serial.println(addr,DEC);
  // Serial.println(E2END,DEC);
}

void loop() { } // do nothing

Now here is the output (or some of it at least).

   0  453D456E676C6973682C20463D467265
  16  6E63682C20533D5370616E6973682C20
  32  493D4974616C69616E2C20413D416C6C
  48  0048656C6C6F20576F726C640042
  64  6F6E6A6F757220746F7574426F6E6A6F
  80  757220746F7574206C65206D6F6E6465
  96  00486F486F6C61206D756E646F00
 112  4369616F206D6F6E646F000436961
 128  6F206D6F6E646F000445008C5
 144  001C3D416CFFFFFFFFFFFFFFFFFFFF
 160  FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
 176  FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
...
 992  FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
1008  FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

I am familiar with non-printing characters but non-value bytes is a new one on me.
I tried adding a delay (upto 100 between each read) in case the EEPROM was really slow.
Same, same …

This is the code that created the missing bytes.

/*	Program: Hello World 005 
        This program stores our Greeting strings in EEPROM.
        These values will remain when the board is turned off.   */
        
#include <EEPROM.h>
/* Addresses in EEPROM */
const word HelpStr =  00;   /* EEPROM location 0000 through 0049 */
const word English =  50;   /* EEPROM location 0050 through 0074 */
const word French  =  75;   /* EEPROM location 0075 through 0099 */
const word Spanish = 100;   /* EEPROM location 0100 through 0024 */
const word Italian = 125;   /* EEPROM location 0125 through 0149 */
const word TheEnd  = 150;   /* the end of our used EEPROM area   */

void setup()
{  storestring (HelpStr, English, "E=English, F=French, S=Spanish, I=Italian, A=All\0"); 
   storestring (English,  French, "Hello World\0");
   storestring (French,  Spanish, "Bonjour tout le monde\0");
   storestring (Spanish, Italian, "Hola mundo\0");
   storestring (Italian,  TheEnd, "Ciao mondo\0");
}

void loop() { } // do nothing 

void storestring (word addrstart, word addrend, char greeting[])
  { byte chrcount = 0;                              // this for the index into our char array
    char singlechar;                                // holds a single character from the array
    for (int addr=addrstart; addr<addrend; ++addr)  // set the address range to write
      { singlechar= greeting[chrcount];             // get one character
        EEPROM.write(addr, singlechar);             // write it to the EEPROM
        if (singlechar=0) { addr = 999;}            // check to see it is string termination 
        ++chrcount;                                 // increment the array index
        delay(10);                                  // allow time for EEPROM write to complete
      }  
  }

It is repeatable. I wrote another program (EEPROM _Clobber) That filled the EEPROM with 0xFF.
The hex dump worked perfectly with that.
Then I ran the “Hello World 005” again and got the same result as I had previously.

I think you probably have the data there, you’re just not seeing it.

    for (i=0; i<16; ++i) 
      {
       Serial.print (EEPROM.read(addr), HEX);
       ++addr;
      }

Printing a HEX value doesn’t give a leading 0. For instance, the sequence 0x67 0x03 0x0E would print as 673E which isn’t what you want.

You need to see if the value is < 0x10, and if it is print an extra 0:

for (i=0; i<16; ++i) 
{
    unsigned char val = EEPROM.read(addr);
    if (val < 0x10) {
        Serial.print("0");
    }
    Serial.print(val, HEX);
    addr++;
}

Serial.print() doesn’t pad with zeros.

Some examples of what different numbers print as:

0 → 0
10 → A
128 → 80
32768 → 8000

Notice how the smaller numbers print fewer characters.

Try this:

byte in = EEPROM.read(addr);
char str[3];
sprintf(str, "%02X",in);
Serial.print(str);

Da … and I knew that regards the decimal address.

#include <EEPROM.h>
unsigned long addr;
byte i, c;

void setup()
{ Serial.begin(9600);
  do { /* ------ Print the address padded with spaces ------ */
       Serial.println("");
       if (addr<1000) {Serial.print(" ");}
       if (addr<100) {Serial.print(" ");}
       if (addr<10) {Serial.print(" ");}
       Serial.print (addr, DEC);
       Serial.print ("  ");
       /*------- Print the Hex Values in groups of 16 ---------*/
       for (i=0; i<16; ++i) 
         { c=EEPROM.read(addr);
           if (c < 0x10) {Serial.print("0");}
           Serial.print (c, HEX);
           ++addr; }
    } while (addr < E2END);   // E2END is the end of the EEPROM
}
void loop() { } // do nothing

Output

   0  453D456E676C6973682C20463D467265
  16  6E63682C20533D5370616E6973682C20
  32  493D4974616C69616E2C20413D416C6C
  48  000048656C6C6F20576F726C64000042
  64  6F6E6A6F757220746F7574426F6E6A6F
  80  757220746F7574206C65206D6F6E6465
  96  0000486F486F6C61206D756E646F0000
 112  4369616F206D6F6E646F000000436961
 128  6F206D6F6E646F000000440500008C05
 144  00001C3D416CFFFFFFFFFFFFFFFFFFFF
 160  FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF