CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

EEPROM PROBLEM

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
leto



Joined: 02 Aug 2005
Posts: 14

View user's profile Send private message

EEPROM PROBLEM
PostPosted: Tue Aug 02, 2005 12:57 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Aug 02, 2005 1:05 pm     Reply with quote

1. What is your version of the compiler ?

2. Post your #use i2c() statement.
Guest








PostPosted: Tue Aug 02, 2005 1:32 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Aug 02, 2005 1:57 pm     Reply with quote

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);
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group