View previous topic :: View next topic |
Author |
Message |
lucasromeiro
Joined: 27 Mar 2010 Posts: 167
|
EEPROM 24LC1025 problem! [Solved] |
Posted: Sat Oct 31, 2015 9:17 am |
|
|
I have a memory EEPROM 24LC1025.
It stores data in it and it never occurred at all.
But now I'm using higher addresses, the memory lock my pic!
What occurs:
to the address 65535 everything works!
after the address 65535 the program crashes!
I did not understand what happens!
As well lock:
write_ext EEPROM (65550,10);
Thus the normal record:
write_text EEPROM (65530,10);
use pic: 18LF2685
Compiler: 5.008
clock: 20mhz
Can anyone help me ??
Looking inside the library 241025.c, I thought this may be something here .:
Code: | void write_ext_eeprom(int32 address, BYTE data)
{
int1 status;
int command;
if (address>65535)command=0xa8; // Check if address is located in Block 0/1
else command=0xa0;
i2c_start();
i2c_write(command);
i2c_write(address>>8);
i2c_write(address);
i2c_write(data);
i2c_stop();
i2c_start();
status=i2c_write(command);
while(status==1)
{
i2c_start();
status=i2c_write(command);
}
}
BYTE read_ext_eeprom(int32 address) {
BYTE data;
int command;
if (address>65535)command=0xa8;
else command=0xa0;
i2c_start();
i2c_write(command);
i2c_write(address>>8);
i2c_write(address);
i2c_start();
i2c_write(command+1);
data=i2c_read(0);
i2c_stop();
return(data);
} |
Last edited by lucasromeiro on Sat Oct 31, 2015 3:58 pm; edited 1 time in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19494
|
|
Posted: Sat Oct 31, 2015 9:55 am |
|
|
The library you should be using, is 241025.c not 241024.c
Then you show command with a floating point number being sent to write_ext_eeprom. This is incorrect syntax. I'm surprised it even compiles.
You have got the A0, and A1 lines grounded?.
and you are sure what part you actually have?.
The 24LC1025, behaves as if it is two 24LC512 chips, one on address 0xA0 (with the address inputs grounded), and the other 8 addresses higher. Hence the code. Run PCM_programmer's I2C scanner program, and verify that a device is showing on address 0xA0/1, and also on 0xA8/9. Have you any other devices on the I2C bus?. If so, are you sure one isn't clashing with the second address.... |
|
|
lucasromeiro
Joined: 27 Mar 2010 Posts: 167
|
|
Posted: Sat Oct 31, 2015 4:01 pm |
|
|
Ttelmah wrote: | The library you should be using, is 241025.c not 241024.c
Then you show command with a floating point number being sent to write_ext_eeprom. This is incorrect syntax. I'm surprised it even compiles.
You have got the A0, and A1 lines grounded?.
and you are sure what part you actually have?.
The 24LC1025, behaves as if it is two 24LC512 chips, one on address 0xA0 (with the address inputs grounded), and the other 8 addresses higher. Hence the code. Run PCM_programmer's I2C scanner program, and verify that a device is showing on address 0xA0/1, and also on 0xA8/9. Have you any other devices on the I2C bus?. If so, are you sure one isn't clashing with the second address.... |
Hello Friend!
Thanks for correcting me.
I am using a translator, because my English is not very good!
the translator has changed (comma) to (point) in charge.
Look again!
The library also fix the name.
As for the program to detect the devices, I already ran and detects normally!
I have 2 other devices, an external ADC and RTC.
Everything works perfectly!
however this problem happens I told you just above now to fix, became clearer. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Nov 01, 2015 12:24 am |
|
|
Quote: | As for the program to detect the devices, I already ran and detects normally! |
Post the results of the i2c bus scanner program. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19494
|
|
Posted: Sun Nov 01, 2015 4:57 am |
|
|
Agreed. Particularly 'how many devices are showing'?. There should be _four_!. The 241025, appears as two devices. I'd be suspicious that one of the other devices is clashing with the second part of the 241025....
What are the part numbers of the ADC, and the RTC?. |
|
|
lucasromeiro
Joined: 27 Mar 2010 Posts: 167
|
|
Posted: Mon Nov 02, 2015 8:23 am |
|
|
The problem has been solved!
The pin3 now has connected to vcc.
before: connected to gnd. (wrong connection!) |
|
|
|