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.

[SOLVED] how to write and read form eeprom 24c32?

Status
Not open for further replies.

manoharn

Junior Member level 2
Joined
Jun 5, 2012
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Bangalore,India
Activity points
1,429
hai i am doing project using pic18f458 and eeprom 24c02 & i done read write operations correctly but its memory is only 256 bytes , i need memory more than this so i choose eeprom 24c32.

In 24c02 i am writing only "one 8bit" data but in 24c32 i need to write "two 8bit" data,so i need to know how to write two 8 bit data.


ex:for 24c02

Code:
let m3=10;//memory location
i2c_eeprom_write(m3,0,dat[0]);

m3=m3+2;

whatever data in the dat[0] its writing to memory location m3 i.e 10 and i don't know o in above i2c_eeprom_write instruction ,in eeprom.c its given like i2c_eeprom_write(unsigned long int addrh,unsigned char addrl,unsigned char data)



any idea for 24c32?
 
Last edited by a moderator:

What's i2c_eeprom_write()? Apparently you are using a specific compiler with a built-in I2C library but forgot to mention it.

Presumedly the library already handles 24C32 addressing...
 

thank u......I am using MPLAB IDE & i added eeprom.c library to the project folder and called in the program.IT is correctly working for 24c02 eeprom.

inside that library the functions like this....


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
void i2c_eeprom_write(unsigned long int addrh,unsigned long int addrl,unsigned long int data)
{
        i2c_start();
        i2c_write(0xA0);                // send chip addr and set data to write mode
        i2c_write(addrh);               // high addr bits
        i2c_write(addrl);               // low addr bits
        i2c_write(data);                // write data
        i2c_stop();
        delay_ms(5);
}
 
/************************** Eeprom Read **************************************/
/**** Reads a single byte from the eeprom supports 2^16 addresses ****/
 
unsigned char i2c_eeprom_read(unsigned long int addrh,unsigned long int addrl)
{
        unsigned char temp;
 
        i2c_start();
 
        i2c_write(0xA0);                // send address data in write mode
        i2c_write(addrh);               // high addr bits
        i2c_write(addrl);               // low addr bits
 
        i2c_start();
        i2c_write(0xA1);                // change to read mode
        temp = i2c_read(0);             // reads are not acknowledged (0)
 
        i2c_stop();                     // if no stop() can get continuous read
 
return temp;
}



but i don't know how to write "two 8bit data"...
 
Last edited by a moderator:

By "two 8bit data" you mean the addressing needed by the eeprom or the data you want to store?

The eeprom needs a control byte, word address1 , word address0, data and these are correctly send by the function you have shown so what is the problem?

Code:
i2c_write(0xA0); // send chip addr and set data to write mode
i2c_write(addrh); // high addr bits
i2c_write(addrl); // low addr bits
i2c_write(data); // write data

- - - Updated - - -

To write the first position use i2c_eeprom_write(0,0,dat[0]);
for the second i2c_eeprom_write(0,1,dat[0]);
the third i2c_eeprom_write(0,2,dat[0]);

you obviously need to use the data you want to write in place of dat[0]
 

Still much confusion...

MPLAB isn't a compiler. We don't know which C-compiler you are using, what the default long data type is etc.

Referring to your original question
but in 24c32 i need to write "two 8bit" data
I thought you are talking about writing 16-Bit addresses, which is correctly done in the shown code. The function parameter type suggests, that you also want to handle 16-Bit data. This is possibly of course, but no problem related to 24C32.

The present code should be able to read and write 8-Bit data from/to 24C32.
 

i am using CCS C Compiler....for eeprom 24c32 i connected 10k pullup resistors to SDA & SCL & wp , a0,a1,a2 connected to gnd...is this connections correct?
 

hai FvM & alexan_e finally i searched 2432.c library, i am trying to understand that library. once i got result i ll get u back.........
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top