Author Topic: DigiX extensive I2C EEPROM library  (Read 21513 times)

Dennis

  • Newbie
  • *
  • Posts: 15
DigiX extensive I2C EEPROM library
« on: July 26, 2013, 01:57:58 am »
Hi,


a few days ago, I started to write a library for my Microchip 24LC256 EEPROM to work seamlessly with my Arduino Due (or the DigiX).
As you will see, all instructions follow the same structure. Here are the functions that my library include:


-bytewise writing/reading: The basic access to your EEPROM.
-- void extEEPROMwrite(int address, byte data_to_be_stored); -> stores one byte at EEPROM address "addr"
-- byte extEEPROMread(int addr); -> reads the EEPROM at address "addr" and returns that value (byte)


You want to store your larger numbers in your external EEPROM? For example sensor values or even a 32 bit integer? You want very easy access to your values, without taking care for the segmentation and reconstruction process? Then take a look at the following ones:
-write/read Sensordata with up to 16 bits: For example your sensor data.
-- void extEEPROMwriteSensor(int addr, int data_to_be_stored);
-- int extEEPROMreadSensor(int addr);


-write/read a complete 32 bit integer: Don't care about sizes, just save your data!
-- void extEEPROMwriteInt(int addr, int data_to_be_stored);
-- int extEEPROMreadInt(int addr);


---> There is absolutely no difference between using byte "write"/"read" or "writeSensor"/"readSensor" + "writeInt"/"readInt"! Ok, if you use the "...Sensor" and "...Int" functions, you have to feed them with integers instead of bytes.

Another cool thing is "page writing/reading". You want to store an array in your EEPROM? No problem!
-write/read pages:
-- void extEEPROMwritePage(int startaddress, byte* data_origin_array, int amount_of_transfered_bytes); -> You have to specify three inputs: 1. The EEPROM address where you want to start writing / 2. a pointer to the array you want to save (see demo) / 3. the size of the array*
-- void extEEPROMreadPage(int startaddress, byte* data_target_array, int amount_of_transfered_bytes); -> Again three inputs: 1. Startaddress / 2. a pointer to an array where you want to save your data / 3. the number of bytes you want to read*

* = Due to the limitations of the Wire Library, you are only able to read 32 bytes / to write 30 bytes at once!!!


You can download my library and a demo sketch at:
https://github.com/IngloriousEngineer/Arduino


Roadmap:
a.) more functions will be included
b.) ability to have more than one EEPROM on a I2C/TWI bus. ---- DONE ✔
c.) Once I have the final specifications, I will adjust my code to work with the DigiX onboard I2C EEPROM!

If you have any questions or want to see a special function in future releases:
PLEASE LEAVE A COMMENT!
« Last Edit: August 02, 2013, 07:35:25 am by Dennis »

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: DigiX extensive I2C EEPROM library
« Reply #1 on: July 26, 2013, 04:11:43 am »
It looks like the final chip will likely be: 24LC32AT-I

Dennis

  • Newbie
  • *
  • Posts: 15
Re: DigiX extensive I2C EEPROM library
« Reply #2 on: August 02, 2013, 07:30:42 am »
This chip should work without any changes! :-)


@Topic: I just updated my library to version 0.4.1!


Changelog:
ver 0.4: Added ability to use multiple EEPROMs on a single I2C/TWI bus.
ver 0.4.1: Successfully tested to work with all current (official) Arduino boards.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: DigiX extensive I2C EEPROM library
« Reply #3 on: September 07, 2013, 02:08:42 am »
Dennis - I hope you don't mind that I have included this in the DigiX addon files for Arduino - with all credit, license, etc left intact of course.


Let me know if you rather it wasn't included.



dfarrell

  • Newbie
  • *
  • Posts: 30
Re: DigiX extensive I2C EEPROM library
« Reply #4 on: March 10, 2014, 05:45:16 pm »
Has anybody tested this on a DigiX?  Doesn't seem to work on mine (V1.0). I did not pursue it, maybe the wrong WIRE port?

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: DigiX extensive I2C EEPROM library
« Reply #5 on: March 11, 2014, 06:30:35 pm »
@dfarrell Are you trying it using the examples included in the DigiX software?

mikkelg

  • Newbie
  • *
  • Posts: 10
Re: DigiX extensive I2C EEPROM library
« Reply #6 on: March 19, 2014, 01:25:03 pm »
i tried using this library and it works like a charm! Good work :)

I have one question though since i have observed that my data is stored in the EEPROM but only until the arduino restarts. If i e.g. program the arduino again or cut power and plug it back in, the loaded values will be nothing near what i stored before. Is this a setting i am missing somewhere that makes the arduino store the values between resets?

TimO

  • Newbie
  • *
  • Posts: 36
Re: DigiX extensive I2C EEPROM library
« Reply #7 on: April 10, 2014, 04:03:14 am »
I have one question though since i have observed that my data is stored in the EEPROM but only until the arduino restarts. If i e.g. program the arduino again or cut power and plug it back in, the loaded values will be nothing near what i stored before. Is this a setting i am missing somewhere that makes the arduino store the values between resets?

I haven't checked the datasheet for this CPU, but the AVR AT90USB1286, which I've been using a lot recently, has a fuse bit "EESAVE" which has to be programmed to retain the EEPROM contents after a Chip Erase.  It could be that something similar is going on here.

gogol

  • Sr. Member
  • ****
  • Posts: 398
Re: DigiX extensive I2C EEPROM library
« Reply #8 on: April 10, 2014, 11:43:44 am »
That has nothing to do with it at all.  The ATSAM3X8E has no build in EEPROM. The EEPROM is on the board connected via I2C.  The problem was, that the TO was writing 4 byte long integers with one byte overlap to the EEPROM.

TimO

  • Newbie
  • *
  • Posts: 36
Re: DigiX extensive I2C EEPROM library
« Reply #9 on: April 11, 2014, 08:26:44 am »
... The ATSAM3X8E has no build in EEPROM. ...

<Doh>  I should have checked things!