Pages: [1]   Go Down
Author Topic: SPI EEPROM & GPS logging  (Read 797 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have got the exact same chip for an EEPROM as stated on the website tutorial for SPIEEPROM. I also got the hardware interfacing and everything to work using the code provided.

http://www.arduino.cc/en/Tutorial/SPIEEPROM

Now I would appreciate some help to understand how to store a "long int" number instead of the "char" as shown in the code. As from the website it seems that you can only write 128 bytes at a time and since in that example they used char (which is 1 byte) they just SPI transfered in the following code:

for (int I=0;I<128;I++)
  {
    spi_transfer(buffer); //write data byte
  }

How would this change for a long int (which is 4 bytes, 32 bits). How would the addressing be affected?

PS: I want to store "latitude, longitude" that comes out of the TinyGPS library functions.

Any sample code or nudge in the right direction to explain the EEPROM addressing and storage will be appreciated.

Thanks

« Last Edit: February 23, 2010, 02:03:18 am by shezi » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 652
Posts: 50850
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have a peek at how it's done here:

http://www.arduino.cc/playground/Code/EEPROMWriteAnything
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

does it also work for SPI interfaced EEPROM?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 652
Posts: 50850
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The techniques for addressing the memory where the long/int/float/double/etc. is stored byte-by-byte will.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34724
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
does it also work for SPI interfaced EEPROM?

No it is for internal memory. The same techinque can be used for external memory but you have to write the bits that actually access the memory.

Look at this for external memory.
http://itp.nyu.edu/~gpv206/2008/04/making_the_most_of_arduino_mem.html
more specifically:-
http://www.arduino.cc/en/Tutorial/SPIEEPROM
« Last Edit: February 25, 2010, 05:11:08 pm by Grumpy_Mike » Logged

Pages: [1]   Go Up
Jump to: