Page 1 of 1

EEPROM Lib, having problems, what am I doing wrong?

Posted: Thu Jun 24, 2021 2:22 pm
by Mangy_Dog
Hi all, So im having issues with the EEPROM emulation on rogers core.

Ive placed

Code: Select all

  EEPROM.PageBase0 = 0x08000000;
  EEPROM.PageSize = 0x400;
  EEPROM.init();
in setup();

somewhere else i call

Code: Select all

  EEPROM.write(0,0);
and then somewhere else I call

Code: Select all

  readCHK = EEPROM.read(0);
and i get back 255.

If i call format, the eeprom block gets formated to 0xffff

This also crashes my program.

I thought the lib is meant to set a partitioned block of flash off from the main program?
Or do i need to place it somewhere else?

Anyway what am i doing wrong?

Re: EEPROM Lib, having problems, what am I doing wrong?

Posted: Thu Jun 24, 2021 6:49 pm
by Mangy_Dog
ok got it working... sort of.

still having some issues.

Code: Select all

  
  EEPROM.PageBase0 = 0x0801F000;
  EEPROM.PageBase1 = 0x0801F400;
  EEPROM.PageSize = 0x400;
  
placing at what i thought would be the last KB of memory in the program. As I was wrong to assume the library partitions off the storage from the program space. So as long as my program doesnt feel the whole memory space up it should be safe...

However. i have some code thats meant to store touch screen config data.

Code: Select all

    if (((EEPROM.read(0) >> 8) != 0x7c))
    {
      GD.self_calibrate();
      // for (int i = 0; i < 24; i++) Serial.println(GDTR.rd(REG_TOUCH_TRANSFORM_A + i), HEX);
      for (int i = 0; i < 12; i++)
        {
          if (i == 0)
            {
              EEPROM.write(0, ((0x7c << 8) | GD.rd(REG_TOUCH_TRANSFORM_A))); // is written!
            }
          else
            {
              EEPROM.write(i, GD.rd( ((REG_TOUCH_TRANSFORM_A + (i * 2)) << 8) | GD.rd(REG_TOUCH_TRANSFORM_A + (i * 2) + 1)));
            }
        }
    }

  else

    {
      for (int i = 0; i < 12; i++)
        {
          if (i == 0)
            {
              GD.wr(REG_TOUCH_TRANSFORM_A + (1), (EEPROM.read(0)) & 0xff); // taking the bottom 8 bits ignoring top 8.
            }
          else
            {
              GD.wr(REG_TOUCH_TRANSFORM_A + (i * 2),(EEPROM.read(i) >> 8 & 0xff)); //& prolly not needed but enforced mask
              GD.wr(REG_TOUCH_TRANSFORM_A + (i * 2) + 1,(EEPROM.read(i) & 0xff));
            }
        }
    }
}

// for reference assuming everything is 8 bits.
//  if ((EEPROM.read(0) != 0x7c))
//    {
//      GD.self_calibrate();
//      for (int i = 0; i < 24; i++)
//        {
//      EEPROM.write(1 + i, GD.rd(REG_TOUCH_TRANSFORM_A + i));
//      EEPROM.write(0, 0x7c);  // is written!
//        }
//    }
//  else
//    {
//      for (int i = 0; i < 24; i++)
//        GD.wr(REG_TOUCH_TRANSFORM_A + i, EEPROM.read(1 + i));
//    }
but when loaded the config data is coming back wrong and the touch screen not accurate. The commented out code is the original loop, where as I took the 8bit data and reworked it to fit the 16bit data address blocks...

But I decided to hard code a few values and the data isnt being stored where I expected and its confusing me...

Image

The data isnt going where i expected. There seems to be loads of header space.... Is something wrong?

Re: EEPROM Lib, having problems, what am I doing wrong?

Posted: Thu Jun 24, 2021 9:01 pm
by mrburnette
Lots of hits in the old static forum: just google as shown...

Code: Select all

eeprom site:stm32duinoforum.com
Re: Saving a Variable in FLASH - MAPLE MINI
Post by RogerClark ยป Fri Sep 01, 2017 10:29 am

https://github.com/rogerclarkmelbourne/ ... ies/EEPROM
You may even have some of the old RTC modules in a box from the Atmega early days, just use the I2C 24C32 eeprom ... you will be much happier.
https://breadboardtronics.wordpress.com ... d-arduino/

Re: EEPROM Lib, having problems, what am I doing wrong?

Posted: Thu Jun 24, 2021 9:44 pm
by Mangy_Dog
kinda seems i got it working now... Reading back seems to work now... still strange behavior that it doesnt appear to write where id expect it to. But reading the address where im writing seems to work now.
I also had a bug in my loop.

As for external eeprom... yeah sure in another project. But this one just has the on board chip flash at the moment.