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.

24LC1026 EEPROM page write problem

Status
Not open for further replies.

Thiliniv

Junior Member level 3
Joined
Nov 20, 2009
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,458
I'm using 24LC1026 EEPROM and Atmega2560 microcontroller. I can successfully write 1 byte to EEPROM. The datasheet(EEPROM"S) says it can write 128 bytes in "page write" . But when i used page write , i can write only first 6 bytes succcessfully. After that no data is written.

Atmel 2560 datasheet also says that it can transfer any number of bytes, continuously. pls help me.
 

are you sure that you don't reach a page barrier?
 

Yes. page barrier starts from FFFF. But even when I started from writing 0x00 also this happpen. So it cannot be a page barrier issue as i think.
 

The page size is 128 so its 0x0 to 0x7F (not 0xFFFF) but you should still be able to write more than 6 bytes for sure

- - - Updated - - -

Yes. page barrier starts from FFFF. But even when I started from writing 0x00 also this happpen. So it cannot be a page barrier issue as i think.

I think you meant the address 0xFFFF so it's correct.
I thought you meant a size of 0xFFFF.
 

ya. it is the address 0xFFFF. Anyway i still cudnt solve the problem. Ar there any control bits that i need to change. ( I read both data sheets. but could not find) Here is my code



Code:
unsigned char eeprom_page_write(unsigned char addressH,unsigned char addressL, unsigned char data[],int length)
{
	unsigned char ucAction1Completed = 0;
	
	unsigned char eepret;
	
	
	eepret = i2c_start(Dev24C02+I2C_WRITE);       // set device address and write mode
    if ( eepret ) {
        /* failed to issue start condition, possibly no device found */
        i2c_stop();
        PORTB=0xAA;                            // activate  LED to show error */
    }else {
        /* issuing start condition ok, device accessible */
        i2c_write(addressH);                       // write address 
		i2c_write(addressL);
		
		for (int i=0; i<length; i++)
		{
			i2c_write(data[i]);                          // write data
			
		}
		
        i2c_stop(); 
		
		ucAction1Completed = 1;
		
	}		
		
}
 

I think the probelm is the way you use an array as the parameter to the function.

Use a pointer like


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
unsigned char eeprom_page_write(unsigned char addressH,unsigned char addressL, unsigned char *data,int length)
{
    unsigned char ucAction1Completed = 0;
    unsigned char eepret;
    eepret = i2c_start(Dev24C02+I2C_WRITE);       // set device address and write mode
 
    if(eepret) {
        /* failed to issue start condition, possibly no device found */
        i2c_stop();
        PORTB=0xAA;                            // activate  LED to show error */
    } else {
        /* issuing start condition ok, device accessible */
        i2c_write(addressH);                       // write address
        i2c_write(addressL);
 
        for(int i=0; i<length; i++)
        {
            i2c_write(*data);                          // write data
            data++;  // increment the pointer address
        }
 
        i2c_stop();
        ucAction1Completed = 1;
    }
}



To call it use the array name

Code:
eeprom_page_write(addressH, addressL, my_array, length);

Alex

- - - Updated - - -

Take a look at https://www.eskimo.com/~scs/cclass/notes/sx10f.html

Even if you write
Code:
unsigned char eeprom_page_write(unsigned char addressH,unsigned char addressL, [COLOR="#FF0000"]unsigned char data[][/COLOR],int length)

The compiler actually does
Code:
unsigned char eeprom_page_write(unsigned char addressH,unsigned char addressL, [COLOR="#FF0000"]unsigned char *data[/COLOR],int length)

so you have to use the appropriately way with a pointer to access the data
 

Problem is still there. Same results.
 

You have used

Code:
            i2c_write(*data);                          // write data
            data++;  // increment the pointer address

and you still write only one character?

Do me a favor and use

Code:
 for(int i=0; i<100; i++)
        {
            i2c_write(0xAA);                          // write data
        }

What is the result?
 

The datasheet says "If an attempt is made to write to the array with the WP pin held high, the device will acknowledge the command, but no write cycle will occur, no data will be written and the device will immediately accept a new command". Verify it.
 

Yes. but no issue with WP.
Anyway thanks a lot. I just solved the problem :). What i did is change the device (EEPROM). Even for the previous 1 , i could write to second block correctly. So may be an issue with that chip.
 

Bu he said that he writes one byte so it can't be a lock situation
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top