View previous topic :: View next topic |
Author |
Message |
leto
Joined: 02 Aug 2005 Posts: 14
|
EEPROM PROBLEM |
Posted: Tue Aug 02, 2005 12:57 pm |
|
|
Hello,
I'm using 24256.c driver to read a previously saved content on IC eeprom. I use the read_ext_eeprom function but sometimes it read ok and sometimes it read dirty characters.
I'm readling 20 continuous characters.
I use a 16f877 and FORCE_HW flag. I have connected the pull ups resistor as well.
Is there any function in order to check the read result or something like that ?.
Thank you
Leto. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 02, 2005 1:05 pm |
|
|
1. What is your version of the compiler ?
2. Post your #use i2c() statement. |
|
|
Guest
|
|
Posted: Tue Aug 02, 2005 1:32 pm |
|
|
compiler ver 3.203
#define EEPROM_SDA=PIN_C4
#define EEPROM_SCL=PIN_C3
#use_i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL, FORCE_HW)
...
...
for (i=0;i<20;i++) {
sChar[i]= read_ext_eeprom( addr + i );
}
sChar[i]=0;
return;
thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 02, 2005 1:57 pm |
|
|
The test program shown below works OK with PCM vs. 3.203
and a 16F877. I tested software i2c and with the FORCE_HW option.
Here is the output:
Quote: |
abcdefghijklmnopqrs
abcdefghijklmnopqrs
abcdefghijklmnopqrs
abcdefghijklmnopqrs
abcdefghijklmnopqrs
abcdefghijklmnopqrs
abcdefghijklmnopqrs
abcdefghijklmnopqrs
abcdefghijklmnopqrs
abcdefghijklmnopqrs |
Here is the test program:
Code: | #include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#define EEPROM_SDA PIN_C4
#define EEPROM_SCL PIN_C3
#include <24256.C>
char sChar[21] = {"Hello World"};
void read_string(int16 addr)
{
int8 i;
for(i=0; i<20; i++)
{
sChar[i]= read_ext_eeprom( addr + i );
}
sChar[i]=0;
}
//=====================================
void main()
{
int8 i;
int16 addr;
addr = 0;
// Write string data to eeprom.
for(i = 0; i < 19; i++)
{
write_ext_eeprom(addr, 'a' + i);
addr++;
}
write_ext_eeprom(addr, 0);
// Read string from eeprom 10 times.
addr = 0;
for(i = 0; i < 10; i++)
{
read_string(addr);
printf("%s\n\r", sChar);
}
while(1);
} |
|
|
|
|