EEPROM Help Needed  (BCD to Hex)

All,

Here is the card with its 4 addresses listed http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&Item=120602029912&Category=4663&_trkparms=algo%3DLVI%26its%3DI%26otn%3D2 Is anyone else usiong this card?

I think my problem is in the conversion of the BCD to hex ...

I have 1010100x as 0x36 (the other chips should be 37,38 and 39) I can not seem to read/write to the card. I have successfully written to the Arduino EEPROM (that was EASY)

Also I am using some code from (I think his name is Richard at DIY-Labs) for reading/writing.

So the first question is -- did I scew up the conversion (this has my vote) or do I really not understand what seemed like pretty simple code.

Thanks for any help!

Dan

I have 1010100x as 0x36

How did you arrive at this conversion?

A web page converting from BCD to hex (because I really do not get it 100% and that is why I think I screwed it up)

I find most of the programming and hardware design I am doing easier than BCD to hex...

A web page

Not trying to be difficult here (that comes naturally), but some particular website?

I didn't see anything on the e-bay site, where they are selling hardware, not information, about what addresses to use. Where did you get them?

Well, I can see 1010100 as 54 in BCD, which is 0x36, but I've never seen a binary notation with the 'x' suffix.

Oh.. on the face of the PCB There are 4 chips with the addresses listed as so... 1010100x 1010101x 1010110x 1010111x

I thought you ment what tool for conversion

Oh, you mean 'x' as in "don't care".

yes, my understanding on this is the last digit is 0 for read and 1 for write

yes these are the chip addresses Data sheet for the chips is here http://www.datasheetarchive.com/24LC32-datasheet.html

here is the code:

define eeprom 0x39

void writeEEPROM(int deviceaddress, unsigned int eeaddress, byte data ) { Wire.beginTransmission(deviceaddress); Wire.send((int)(eeaddress >> 8)); // MSB Wire.send((int)(eeaddress & 0xFF)); // LSB Wire.send(data); Wire.endTransmission(); }

//read eeprom function

byte readEEPROM(int deviceaddress, unsigned int eeaddress ) { byte rdata = 0xFF; Wire.beginTransmission(deviceaddress); Wire.send((int)(eeaddress >> 8)); // MSB Wire.send((int)(eeaddress & 0xFF)); // LSB Wire.endTransmission(); Wire.requestFrom(deviceaddress,1); if (Wire.available()) rdata = Wire.receive(); return rdata; }

Not getting anywhere? How can we not be getting anywhere? We're zig-zagging all over the place.

Data sheet for the chips is here

Instead of posting a link to a (useless) e-bay add, you should have posted this (useful) link in the first place.

Next time, you'll know better. I hope.

The ebay add has the device with the pictures of the addresses on each chip.

but, yes, I should have included the Datasheet link..

the device address is defined as 1010100 (for the first chip). it is defined by applying +5V to the A0, A1 or A2 pins (+5 = a 1 and 0V = a zero) for the last 3 digits of the address

Suerly the addresses are binary :

1010100x where x is undefined, BCD is irellevent just convert to hex

1010 = A

1000 = 8

0xA8 (or 9 depending on the last bit!)

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1280095224

Here is someone working with these chips -- this code does not seem to work for me either (I went with the 0x54 address per his code) but all I get is jibberish.

I think for now I will stick with the 512 Bytes built in to the arduino -- it wil get the job done for now, and it works...

@Danm- Thats a pretty cool board. We should be able to get it going for you.

(In the future, when you post code, click the “#” button above in the toolbar, and cut-n-paste.)

// They can be also put to either ground or Vcc to control up to 8 memory chips (2^3), giving you 2MBit of memory (8*2^15).
// A2 A1 A0 Binary Address Hex Address
// 0  0  0    0b1010000       0×50
// 0  0  1    0b1010001       0×51
// 0  1  0    0b1010010       0×52
// 0  1  1    0b1010011       0×53
// 1  0  0    0b1010100       0×54
// 1  0  1    0b1010101       0×55
// 1  1  0    0b1010110       0×56
// 1  1  1    0b1010111       0×57

The screening on the board is a little misleading, but correct. The ‘x’ is a bit filled in by the Arduino Wire library based on the ‘read or write’ status. Note the code (ok, comments from code) above. 0b means the numbers are in binary. Note they all have a MSB (Most Signifigant Byte) of 1010. This is the family code.

The last three bits (ok, four with the bit the Arduino fills in for us) is the address.(LSB, or Least Signifigant Byte) This is determined by which pins (a0,a1 and a2) are connected to ground. Your board has four of eight addresses used, 100,101,110 and 111.

You were right on using the address 0x54. That is 0b1010100, ( or DEC 84, or 0x54), the chip on the upper left.

Wait. I see from the EBay pics you have (4) 24LC32 chips on the board.

THAT may explain a lot. :o (OK, it is early here. I just got up)

Now, all (4) of those chips give you 128K bits (NOT Bytes) together. This is 1/2 of the memory of a 24LC256 chip that my other code was written for. Not a bunch of storage, but lets “use what ya got”.

Other differences:

Page write size of 32 Bytes, not 64 like the 24LC256.
Memory addresses are 0x000 to 0xFFF (24LC256 is 0x0000 to 0x7FFF)
128 (32Byte) ‘blocks’ of memory, 1024 (32Byte) ‘blocks’ in the 24LC256

Hmmm…

Try this to write F1 thirty times, and F2 twice per page until chip memory is full:

// Some code to overwrite F1 and F2 (or other chosen values) in all memory locations in a 24LC32a
// mashup from Volkemon 8/2010 for Danm



#include <Wire.h>  


char chipAdress=0x54;   // 24LC32a address on the bus

int startAddress = 0;      //overall counter for address location. 16 bit value, will be split into MSB and LSB  
byte startaddrMSB = 0x00; // Most Signifigant Byte, 1/2 of the address in chip memory.         Max val 0x0F
byte startaddrLSB = 0x00; // Least Signifigant Byte, other 1/2 of the address in chip memory.  Max val 0xFF
                      



void setup()

{
  Wire.begin();             // enable the i2c bus
  Serial.begin(9600);      // Make sure you set the serial monitor to match! :)


}



void loop()
{

  
    Serial.print("Writing starting at bit/slot "); Serial.print(startAddress, DEC);  // info sent to serial monitor for debugging.
  Wire.beginTransmission(chipAdress);    // chip address on the TWI bus, not chip memory address.
  
                  //Set up the chip Internal Address Pointer to the desired location
                  
  startaddrMSB = highByte(startAddress);
  startaddrLSB = lowByte(startAddress);  
  Wire.send(startaddrMSB);      //First  7 bits of the address
  Wire.send(startaddrLSB);     //Second 8 bits of the address
  
  for (byte ct=0x0; ct<30; ct++)  // loop where we write info to Wire library buffer.30 byte max. first two are used for address.
  {
    
   Wire.send(0xF1);  // sends F1 to wire buffer
   startAddress ++;
   if (startAddress >= 0x0FFF){
     Serial.print("OVERWRITE COMPLETE");
     startAddress = (-1);    // if set to zero, address is off by 1 after 1st overwrite. WHY???
     delay(5000);
   }
                    
  }
  Wire.endTransmission();      // commands write of data from Wire library buffer to chip , 'closes' chip
  
  Serial.print(" Done1.");Serial.print(startAddress);
  
  


 // The first loop sent 30 packets, leaving 2 open in the page. This cleans them up, and gets the Internal Address Pointer to an page beginning.


    Wire.beginTransmission(chipAdress);    // chip address on the TWI bus, not chip memory address.
  
                  //Set up the chip Internal Address Pointer to the desired location
  startaddrMSB = highByte(startAddress);
  startaddrLSB = lowByte(startAddress);  
  Wire.send(startaddrMSB);      //First  7 bits of the address
  Wire.send(startaddrLSB);     //Second 8 bits of the address
  
  for (char ct=0x0; ct<2; ct++)  // loop where we write info to Wire library buffer. 2 to fill up the page.
  {
    
   Wire.send(0xF2);   // Sends the value 0xF2 to Wire library buffer.
   startAddress++;
   if (startAddress >= 0x0FFF){
     Serial.print("OVERWRITE COMPLETE");
     startAddress = (-1);     // if set to zero, address is off by 1 after 1st overwrite. WHY???
     delay(5000);
   }
  }
  
  Wire.endTransmission();      // commands write of data from Wire library buffer to chip , 'closes' chip
  
   Serial.print(" Done3."); Serial.println(startAddress);
  
}

And this to read it:

// sketch to read entire chip 32 bytes at a time, display on serial monitor with progress indicated.
// Aug2010- Volkemon tweaked and commented for use with 24LC32a for Danm
//      _ _
//  A0-|oU |-Vcc
//  A1-|   |-WP
//  A2-|   |-SCL
// Vss-|   |-SDA
//      ---
//
//   SDA goes to Arduino 4
//   SCL goes to Arduino 5
//   WP  goes to ground for now. Can be put to Vcc if write protection is needed.
//   Vcc goes to arduino Vcc
//   Vss goes to arduino ground
//   A2, A1, A0 go to ground for now.
//
// They can be also put to either ground or Vcc to control up to 8 memory chips (2^3), giving you 2MBit of memory (8*2^15).
// A2 A1 A0 Binary Address Hex Address
// 0  0  0    0b1010000       0×50
// 0  0  1    0b1010001       0×51
// 0  1  0    0b1010010       0×52
// 0  1  1    0b1010011       0×53
// 1  0  0    0b1010100       0×54
// 1  0  1    0b1010101       0×55
// 1  1  0    0b1010110       0×56
// 1  1  1    0b1010111       0×57
  
#include <Wire.h>

char chipAdress=0x54;        // Binary 10100000 . Three bits after 1010 (currently 000) are used to specify to what A2, A1, A0 are connected to, ground or vcc. See comment above.
                      // Last bit specifies the opertation - 0 for write, 1 for read. This is controlled for you by the Wire library. :)
int block = 0;



void setup()

{
  Wire.begin();           // enable the i2c bus
  Serial.begin(9600);   // Did you set your serial monitor to 9600?
  Wire.beginTransmission(chipAdress);    // chip address on the TWI bus, not chip memory address.
  
                  //Set up the chip Internal Address Pointer to the beginning of memory

  Wire.send(0x00);      
  Wire.send(0x00);    
  
  Wire.endTransmission(); // sends Wire buffer to chip, sets Internal Address Pointer to '0'
  
  
}

void loop()
{
  Serial.println("");
  Serial.print(block);
  Wire.requestFrom(chipAdress, 32);          // requests 32 Bytes of data in a packet, maximum string size.
  while(Wire.available()){                // 'while loop' start, Checks to see if data is waiting
    Serial.print("  ");                  // space to format packets on serial monitor
    Serial.print(Wire.receive(), HEX);  // print the values received on the serial monitor
  }                                    // end bracket for 'while loop'
  Wire.endTransmission();           // when 'while loop' is finished (no more data available) 'closes' chip
  //Serial.println("");
  block += 1;
  if (block > 128){
    Serial.println("End Of Memory");
    delay(5000);
  }
  delay(100);
}

Both sketches compile, but I have no 24LC32a to try them on. See if they work for you.

Thanks!

I will upload the sketches when I get home tonight.

This would be nice to have a simple removable memory chip for data logging on my application, I have my other system variables stored on the Arduino’s onboard EEPROM

For an EBay posting, that is pretty complete.

I note now that the IC's are in removable sockets, and that A2 (pin3) is tied to Vcc in all cases. This would make this a good breakout board for the 24LC08B. It only uses A0 and A1 and can have 4 together on a single bus. The '08 is the chip that got me into this series, and has a page write size of 16 Bytes! Total memory of 1KB. NOT a good alternative to what you have. ;)

However... I have no experience with them,(yet) but it looks like the 24LC1025 is a drop in replacement for the 24LC32a's on your board, and the -1025's also need to have A2 tied to Vcc. Write the correct code and you could have a 500 KByte ( 4Mbit ) memory board!

http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=24LC1025-I/P-ND