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 CCS Technical Support

Internal EEPROM 16F877 - No Retention (PCW 3.222)

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



Joined: 16 Mar 2005
Posts: 1

View user's profile Send private message

Internal EEPROM 16F877 - No Retention (PCW 3.222)
PostPosted: Wed Apr 06, 2005 7:29 am     Reply with quote

I cannot seem to keep values in the PIC16F877 Internal EEPROM when I shut down the PCS Debugger or power-cycle. If I run within the PCW debugger, my code set the values (using write_EEPROM(), see below) and when I refresh the Data EE the values are there. If I reset the MPU, the values are still there. If I close the PCW Debugger and then re-open it, the EEPROM values are gone, replaced with 0xFF (except for location 0x02, which is correct). #fuse NOPROTECT is being used. Now when the code runs, it's as though no values were set. Am I seeing a side-effect of the PCW Debugger or am I missing something?

Thanks, Vernon Davis

#FUSES:
NOWDT, HS, NOPUT, NOPROTECT, NOBROWNOUT, NOLVP, NOCPD, NOWRT, DEBUG


CODE:
//==========================================================================
void init_EEPROM(void) {
BYTE rev, inv_rev, tst_rev;
WORD i;

// Location 0 is the revision
// - The high nibble is the major revision
// - The low nibble is the minor revision
// Location 1 is the the inverse of the revision
rev = read_EEPROM(EEP_REVISION);
inv_rev = read_EEPROM(EEP_INV_REVISION);

// If Location 0 is not equal to the inverse of Location 1,
// then the EEPROM has not been initialized.
if (rev != ~inv_rev) {
set_Default_Label_Number(2);
set_Handshake_Protocol(AUTO_PROTOCOL);
for (i=1; i<16; i++) {
set_Motor_Speed(i, DEFAULT_MOTOR_SPEED);
set_Pick_Delay(i, DEFAULT_PICK_DELAY);
set_Label_Timeout(i, DEFAULT_LABEL_TIMEOUT);
}

// Write zeroes to designated EEPROM locations
for (i=128; i<256; i++) write_EEPROM(i, 0);
}

// If revision has changed, re-write it and the inverse
tst_rev = ((BYTE)(MAJOR_REV) << 4) | ((BYTE)(MINOR_REV));
if (tst_rev != rev) {
write_EEPROM(EEP_REVISION, tst_rev);
inv_rev = ~tst_rev;
write_EEPROM(EEP_INV_REVISION, inv_rev);
}
}

//==========================================================================
BYTE get_Default_Label_Number(void) {
return read_EEPROM(EEP_DEF_LBL_NO);
}

//==========================================================================
void set_Default_Label_Number(BYTE value) {
write_EEPROM(EEP_DEF_LBL_NO, value);
}

//==========================================================================
BYTE get_Motor_Speed(BYTE idx) {
return read_EEPROM((EEP_LABEL_1 + ((idx - 1) * 8)));
}

//==========================================================================
void set_Motor_Speed(BYTE idx, BYTE value) {
write_EEPROM((EEP_LABEL_1 + ((idx - 1) * 8)), value);
}

//==========================================================================
BYTE get_Pick_Delay(BYTE idx) {
return read_EEPROM((EEP_LABEL_1 + ((idx - 1) * 8)) + 1);
}

//==========================================================================
void set_Pick_Delay(BYTE idx, BYTE value) {
write_EEPROM((EEP_LABEL_1 + ((idx - 1) * 8)) + 1, value);
}

//==========================================================================
BYTE get_Label_Timeout(BYTE idx) {
return read_EEPROM((EEP_LABEL_1 + ((idx - 1) * 8)) + 2);
}

//==========================================================================
void set_Label_Timeout(BYTE idx, BYTE value) {
write_EEPROM((EEP_LABEL_1 + ((idx - 1) * 8)) + 2, value);
}

//==========================================================================
BYTE get_Handshake_Protocol(void) {
return read_EEPROM(EEP_PROTOCOL);
}

//==========================================================================
void set_Handshake_Protocol(BYTE value) {
write_EEPROM(EEP_PROTOCOL, value);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 06, 2005 9:49 am     Reply with quote

http://www.ccsinfo.com/forum/viewtopic.php?t=21777&highlight=eeprom
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