Jump to content
Sign in to follow this  
Carlos

Eeprom Read On Power Up Not Working Right

Recommended Posts

I'm using a 16F883 chip.

EEProm read on power up does not reflect the last value written.

Subsequent power ups advance count by 1 or more.

Sometimes goes to 00.

 

Also I can not add eeprom.pic16.lib to project.

Including eeprom.h works OK.

 

Here is the code:

 

 

void Write_Last_Channel() //Normal write eeprom routine

{

// Last channel stored 0x79,7A,7B, 7C

 

eedata = Minus;

eeadr = 0x79;

set_bit(eecon1,WREN);

clear_bit(intcon,7);

eecon2 = 0x55;

eecon2 = 0xaa;

set_bit(eecon1,WR);

while (eewait == 1);

clear_bit(pir1,EEIF);

clear_bit(eecon1,WREN);

eedata = Ch;

eeadr = 0x7A;

set_bit(eecon1,WREN);

clear_bit(intcon,7);

eecon2 = 0x55;

eecon2 = 0xaa;

set_bit(eecon1,WR);

while (eewait == 1);

clear_bit(pir1,EEIF);

clear_bit(eecon1,WREN);

 

HIBYTE(eedata,PLLData);

eeadr = 0x7B;

set_bit(eecon1,WREN);

clear_bit(intcon,7);

eecon2 = 0x55;

eecon2 = 0xaa;

set_bit(eecon1,WR);

while (eewait == 1);

clear_bit(pir1,EEIF);

clear_bit(eecon1,WREN);

 

LOBYTE(eedata,PLLData);

eeadr = 0x7C;

set_bit(eecon1,WREN);

clear_bit(intcon,7);

eecon2 = 0x55;

eecon2 = 0xaa;

set_bit(eecon1,WR);

while (eewait == 1);

clear_bit(pir1,EEIF);

clear_bit(eecon1,WREN);

set_bit(intcon,7);

}

 

 

void Read_Last_Channel() //Get last channekl used here on startup......

{

eeadr = 0x79;

set_bit(eecon1,RD);

Minus = eedata;

eeadr = 0x7a;

set_bit(eecon1,RD);

Ch = eedata;

eeadr = 0x7b;

set_bit(eecon1,RD);

WrHi = eedata;

eeadr = 0x7c;

set_bit(eecon1,RD);

WrLo = eedata;

MAKESHORT(PLLData,WrLo,WrHi);

Load_PLL();

Channels();

Segments();

}

 

Can anyone help me?

 

Carl

Share this post


Link to post
Share on other sites

Hi

 

I noticed that, when reading the EEPROM, there is no instruction to clear the EPGD bit in EECON1.

Maybe you are getting vakues from the program memory instead of the EEPROM.

 

By the way, are you sure the proper values are beeing writen to the EEPROM?

Have you read the EEPROM with the programmer, and found out that the proper values are there?

 

 

About the inclusion of "eeprom.pic16.lib", you must be more specific on what is happening.

 

 

Best regards

Jorge

Edited by JorgeF

Share this post


Link to post
Share on other sites

Hi

 

Yes the correct bytes are written. It works sometimes.

 

I will try the data bit.

 

Can you tell me how to include that lib? I tried many ways.

I get a preprocessor error.

Will it work with 883 chips?

 

Carl

Share this post


Link to post
Share on other sites

Hi

 

Including a "lib" file as nothing to do with the pre-processor.

Libs are a colection of object code modules that the "linker" joins to your project on a need basis.

 

Any pre-processor error must be related to problems in the source code (including ".h" files).

Unless of course you are trying to add a lib with an "#include" directive. But that is not the correct way, as the "lib" files are collections of object code modules.

 

Besides the default "lib" that is automaticaly selected and searched during the "build" process (based on the selected target), all others must be explicitly added to the project.

 

The correct way is to add the needed "lib" file to the project the same way you would add a source file.

In the workspace window, right click on the project name and choose "add files ...."

 

 

Considering that the PIC16F883 is one of the BoostC supported devices, all the libs provided by SourceBoost should work, unless otherwise noted in the documentation.

 

 

 

 

Best regards

Jorge

Edited by JorgeF

Share this post


Link to post
Share on other sites

That's simple. I was trying to include it.

 

I'll get back on it tomorrow.

 

Thanks...

 

Carl

Edited by Carlos

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...