Go Down

Topic: How to define 24c64 and 24c256 in the same sketch (Read 275 times) previous topic - next topic

wukrupa

Hi, I'm new in this, I need help to define 24c64 and 24c256 in the same sketch I use the library
#include <EEPROM24.h>
#include <I2CMaster.h>
#include <SoftI2C.h>
SoftI2C i2c(10,11); // SDA=10, SCL=11........

the error is here I can not select one of the two can be defined with sw?


if (pina==1)EEPROM24 eeprom(i2c,EEPROM_24LC64);
if (pinb==0)EEPROM24 eeprom(i2c,EEPROM_24LC256);

sterretje

What is the error that you get?

Can you post the complete code (using code tags as described in point #7 in How to use this forum - please read) that exhibits the error?

Why are you using software I2C?

Which board are you compiling for?
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

wukrupa

Thanks for answering
I do not know if I can upload the entire code because it is not mine, I just want to modify it to be able to use it with different eeprom.
I'm using arduino nano
the code works only that I do not know how to use the i2c library that is from elektor-magazine I do not know if it breaks any rule of the forum this is the link of the project
https://www.elektormagazine.com/labs/a-universal-through-hole-audio-dsp-board-based-on-the-adau1701-130232-i#/comments/labs/211

What I want to do is use a pin as switch to change from 24c64 to 24c256

Can I change ic eeprom while another is initialized?
I already asked the one who did the project but he does not answer

GolamMostafa

#3
Oct 14, 2018, 07:08 pm Last Edit: Oct 14, 2018, 07:09 pm by GolamMostafa
@OP

Do you want to opertae 24C64 and 24C256 EEPROMs simultaneously? To do it, you assign address 0x50 (1010A2A1A0 = 1010000) for 24C256 and address 0x57 (1010A2A1A0 = 1010111) for 24C64. Now, the chips have different I2C Bus addresses and you can very well perform data read/write operations.

Sample codes:
Code: [Select]
#include<Wire.h>

void setup()
{
   Serial.begin(9600);
   Wire.beginTransmission(0x50); //accessing 24C256
   Wire.write(0x12); //upper byte of location address 0x1234
   Wire.write(0x34); //lower byte of location address 0x1234
   Wire.write(0x57); //data for location 0x1234;
   Wire.endTransmission();
   delay(5);     //must wait for 5 ms as it is write cycle time
}

   Wire.beginTransmission(0x50); //accessing 24C256
   Wire.write(0x12); //upper byte of location address 0x1234
   Wire.write(0x34); //lower byte of location address 0x1234
   Wire.endTransmission();

   Wire.requestFrom(0x50, 1); //command to read data from location 0x1234
   byte x = Wire.read();    //data in x
   Serial,print(x, HEX); //serial monitor should show 57

  //=== repeat the aboce code for 24C64 EPROM at I2C address 0x57 and data location 0x1278.

}

void loop()
{

}

Go Up