Go to Post ...it takes a very special kind of person to equate bagpipes with harps. - Kevin Sevcik [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 16-03-2004, 16:35
DKolberg DKolberg is offline
Mentor Iron Giants
AKA: David Kolberg
FRC #5069 (Iron Giants)
Team Role: Mentor
 
Join Date: May 2002
Rookie Year: 2000
Location: South Bend
Posts: 44
DKolberg has a spectacular aura aboutDKolberg has a spectacular aura about
Question Problem with reading and writing EEPROM

I have copied the code found elsewhere into eeprom.h and eeprom.c and all I can get in the read is 0xFF. I have tried manual reads of the eeprom using the raw code

// Load address into address register
EEADRH = 0;
EEADR = 1

//Configuration as per manual
EECON1bits.EEPGD = 0;
EECON1bits.CFGS = 0;
EECON1bits.RD = 1;

printf("eeprom read address High %d, Low %d, Value %d\n",
(int) EEADRH, (int) EEADR, (int) EEDATA);

I have a similar printf statement in the write eeprom routine and all I get is 0xFF for data reads.

I will try a direct write in the initialize area and then modify the code to do a direct read in the initialize area to see if that works.

Any other suggestions?

Dave Kolberg
  #2   Spotlight this post!  
Unread 16-03-2004, 16:46
Random Dude Random Dude is offline
Oregon State Head FTA
AKA: Chris
no team (Oregon Robotics Tournament & Outreach Program)
 
Join Date: Aug 2002
Rookie Year: 1998
Location: Oregon
Posts: 142
Random Dude will become famous soon enoughRandom Dude will become famous soon enough
Re: Problem with reading and writing EEPROM

Hmm..

First off, for anyone who missed the original discussion on EEPROM, I suggest you go check that out.

That being said, 0xFF is the inital value of the EEPROM unless data is written to it. So your problem is with your write function.

Could you post your function calls to the EEPROM library?
  #3   Spotlight this post!  
Unread 16-03-2004, 17:31
DKolberg DKolberg is offline
Mentor Iron Giants
AKA: David Kolberg
FRC #5069 (Iron Giants)
Team Role: Mentor
 
Join Date: May 2002
Rookie Year: 2000
Location: South Bend
Posts: 44
DKolberg has a spectacular aura aboutDKolberg has a spectacular aura about
Re: Problem with reading and writing EEPROM

Quote:
Originally Posted by Random Dude
Hmm..

First off, for anyone who missed the original discussion on EEPROM, I suggest you go check that out.

That being said, 0xFF is the inital value of the EEPROM unless data is written to it. So your problem is with your write function.

Could you post your function calls to the EEPROM library?
I have tried writing the following in the User_Initialization routing:

EEADR = 1;
EEADRH = 0;
EEDATA = 5;

EECON1bits.EEPGD = 0;
EECON1bits.CFGS = 0;
EECON1bits.WREN = 0;
INTCONbits.GIE = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1;
INTCONbits.GIE = 1;
EECON1bits.WREN = 0;

downloaded and ran once then changed to the following:

EEADR = 1;
EEADRH = 0;

EECON1bits.EEPGD = 0;
EECON1bits.CFGS = 0;
EECON1bits.RD = 1;

printf("eeprom read address high %d, low %d, value %d\n",
(int) EEADRH, (int) EEADR, (int) EEDATA);

and the value printed is 255

Dave
  #4   Spotlight this post!  
Unread 16-03-2004, 17:44
Random Dude Random Dude is offline
Oregon State Head FTA
AKA: Chris
no team (Oregon Robotics Tournament & Outreach Program)
 
Join Date: Aug 2002
Rookie Year: 1998
Location: Oregon
Posts: 142
Random Dude will become famous soon enoughRandom Dude will become famous soon enough
Re: Problem with reading and writing EEPROM

Quote:
Originally Posted by DKolberg
I have tried writing the following in the User_Initialization routing:

EEADR = 1;
EEADRH = 0;
EEDATA = 5;

EECON1bits.EEPGD = 0;
EECON1bits.CFGS = 0;
EECON1bits.WREN = 0;
INTCONbits.GIE = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1;
INTCONbits.GIE = 1;
EECON1bits.WREN = 0;
Actually, your write command should be this



EECON1bits.EEPGD =0;
EECON1bits.CFGS =0;
EECON1bits.WREN =1;
INTCONbits.GIE = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1;
INTCONbits.GIE = 1;
EECON1bits.WREN = 0;

The difference being WREN is set to 1 the first time, not 0.
  #5   Spotlight this post!  
Unread 16-03-2004, 19:29
DKolberg DKolberg is offline
Mentor Iron Giants
AKA: David Kolberg
FRC #5069 (Iron Giants)
Team Role: Mentor
 
Join Date: May 2002
Rookie Year: 2000
Location: South Bend
Posts: 44
DKolberg has a spectacular aura aboutDKolberg has a spectacular aura about
Talking Re: Problem with reading and writing EEPROM

Quote:
Originally Posted by Random Dude
Actually, your write command should be this



EECON1bits.EEPGD =0;
EECON1bits.CFGS =0;
EECON1bits.WREN =1;
INTCONbits.GIE = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1;
INTCONbits.GIE = 1;
EECON1bits.WREN = 0;

The difference being WREN is set to 1 the first time, not 0.
That fixed it, it works. Thank you, Thank you, Thank you.

Dave
SBOTZ
Team 1327
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:55.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi