@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.