Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

i2c eeprom(AT24C32A) interfacing with arduino

Status
Not open for further replies.

badri89

Junior Member level 3
Joined
Oct 19, 2009
Messages
29
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Location
india
Activity points
1,484
Hi I am trying to log the temperature sensor readings to an external eeprom(AT24c32a) using arduino and using the following program
Code:
#include <Wire.h>
int pin=0;
void i2cexeepromwrite(int slaveaddress,int whichaddress,int data)
{
  Wire.beginTransmission(slaveaddress);
  Wire.send(whichaddress>>8);
  Wire.send(whichaddress & 0xFF);
  Wire.send(data);
  Wire.endTransmission();
  delay(100);
}
byte i2cexeepromread(int slaveaddress,int whichaddress)
{
  int res;
  Wire.beginTransmission(slaveaddress);
  Wire.send((byte)whichaddress>>8);
  Wire.send((byte)whichaddress & 0xFF);
  Wire.endTransmission();
  Wire.requestFrom(slaveaddress,1);
  if(Wire.available())
  res=Wire.receive();
  return res;  
}
void setup()
{
  Wire.begin();
  Serial.begin(9600);
}
void loop()
{
int val,a;
float temp;
val=analogRead(pin);
temp=(5*val*100)/1024;
Serial.println(temp);
for(a=0;a<10;a++)
{
  Serial.println("Writing now");
  i2cexeepromwrite(0x50,a,temp);
  Serial.println("Now Read");
  i2cexeepromread(0x50,a);
}

  
}


I found that nothin is getting displayed in the serial monitor and data is not at all getting written in the external eeprom also.Am i missing something?please help me out.

---------- Post added at 20:13 ---------- Previous post was at 19:50 ----------

In the datasheet of the eeprom it is given as
The 32K/64K is internally organized as 128/256 pages of 32 bytes each. Random word addressing requires a 12/13-bit data
word address.

So does this mean the address is 12 bits for my program..so instead of >>8 it should be >>6 and similarly for 0xff??please clarify me.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top