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 on pic16f877

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 18, 2003 5:40 pm     Reply with quote

I ran the following test program with PCM vs. 2.734. It works fine.
It displays the following on the terminal window:

Start

Wrote 0x55 to eeprom address 0
Read 55

Wrote 0xAA to eeprom address 0
Read AA

Done


Try this program. If you're using a 4 MHz crystal, then change
the HS to XT. Also change the #use delay clock to 4000000.

Code:
#include <16F877.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 8000000)
#use rs232(baud = 9600, xmit=PIN_C6, rcv = PIN_C7, ERRORS)
//===========================================

main()
{
printf("Start\n\r\n\r");

write_eeprom(0, 0x55);
printf("Wrote 0x55 to eeprom address 0\n\r");
printf("Read %X\n\r", read_eeprom(0));
printf("\n\r");

write_eeprom(0, 0xAA);
printf("Wrote 0xAA to eeprom address 0\n\r");
printf("Read %X\n\r", read_eeprom(0));

printf("\n\rDone\n\r");

while(1);
}
 
Guest








PostPosted: Tue Nov 18, 2003 10:00 pm     Reply with quote

Smile Thanks, I not sure what I've done but everything seems to be working!

Thanks

Again.
csanders



Joined: 23 Apr 2005
Posts: 16

View user's profile Send private message

PostPosted: Fri Aug 10, 2007 2:34 pm     Reply with quote

PCM Programmer:

I am having a similar problem as well. I tried you test program, but I still can't modify the EEPROM when doing a write.

What is odd is that I can change the EEPROM values when downloading a new program via the #ROM statement & in the CCS Debug IDE, just not at runtime.

I have tried this on another MCU, but still no luck.


What is really driving me nuts is that this worked on a project I did a year ago using the exact same board. I think it must be a Fuse problem, but I can't figure it out.

Here are the Fuse settings read from the ICD Utility:
HS
NOOSCSEN
NOBROWNOUT
WDT128
NOWDT
BORV25
NOPUT
NOWAIT
MCU
CCP2C1
STVREN
DEBUG
NOLVP
NOPROTECT
NOCPD
NOCPB
NOWRT
NOWRTD
NOWRTC
NOWRTB
NOEBTR
NOEBTRB



The MCU is an 18F8720, and I am using compiler version 4.033.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 10, 2007 2:51 pm     Reply with quote

I notice you have the DEBUG fuse set. Are you stepping through this
code with the debugger, or placing breakpoints ?

According to the ICD2 help file, the Data EEPROM window will not
show updated values unless you read the data eeprom. In other
words, if you place a breakpoint just after the write_eeprom()
function, but before the read_eeprom(), you won't see updated
values. It will appear to not be writing to the eeprom.
Place the breakpoint on a line after the read_eeprom() function.
csanders



Joined: 23 Apr 2005
Posts: 16

View user's profile Send private message

PostPosted: Fri Aug 10, 2007 3:35 pm     Reply with quote

I place the breakpoint before the write_eeprom instruction, and step through the instruction past the read_eeprom function. I verify the value returned from the read by hovering over the variable returned by the read function. I also refresh the Data EE window in the debug window to determine if the EEPROM data has been updated.

Can you think of anything else it might be?

Thanks for the help
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 10, 2007 3:38 pm     Reply with quote

Try running the posted program as a "stand alone" program.
Run it actual hardware. Don't use the debugger. Have the
output go to a terminal window on your PC. See if it works.
csanders



Joined: 23 Apr 2005
Posts: 16

View user's profile Send private message

PostPosted: Mon Aug 13, 2007 7:24 am     Reply with quote

OK - The write function works if I am not debugging on the MCU. Is this a bug that needs to be reported, or is there something I can do on my end to make this work properly with the ICD?
Pret



Joined: 18 Jul 2006
Posts: 92
Location: Iasi, Romania

View user's profile Send private message

PostPosted: Tue Aug 14, 2007 6:56 am     Reply with quote

Not that there is a number of 16F877 PIC's on the market which contains a bug in the first 4 bytes of the EE. Personally i have one of it and i found the Microchip related errata. As general hint, try to skip those first 4 bytes of EE.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 14, 2007 10:51 am     Reply with quote

I couldn't find an errata on the 16F877 that says the first four bytes
of eeprom have a bug. Here's the 16F877 page, with links to the three
errata documents on the lower right side.
http://www.microchip.com/stellent/idcplgidcplg?IdcService=SS_GET_PAGE&nodeId=1335&dDocName=en010241

I also did a search of the Microchip site with Google. I didn't see any
such errata. I used these search strings:
Quote:
site:microchip.com 16F877 eeprom errata

Quote:
site:microchip.com 16F877 eeprom bug

If you have an errata on this, then post a link to it.
nirayo



Joined: 23 Feb 2009
Posts: 10

View user's profile Send private message

read_eeprom & write_eeprom
PostPosted: Wed Mar 11, 2009 8:35 am     Reply with quote

PCM programmer wrote:
I ran the following test program with PCM vs. 2.734. It works fine.
It displays the following on the terminal window:

Start

Wrote 0x55 to eeprom address 0
Read 55

Wrote 0xAA to eeprom address 0
Read AA

Done


Try this program. If you're using a 4 MHz crystal, then change
the HS to XT. Also change the #use delay clock to 4000000.

Code:
#include <16F877.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 8000000)
#use rs232(baud = 9600, xmit=PIN_C6, rcv = PIN_C7, ERRORS)
//===========================================

main()
{
printf("Start\n\r\n\r");

write_eeprom(0, 0x55);
printf("Wrote 0x55 to eeprom address 0\n\r");
printf("Read %X\n\r", read_eeprom(0));
printf("\n\r");

write_eeprom(0, 0xAA);
printf("Wrote 0xAA to eeprom address 0\n\r");
printf("Read %X\n\r", read_eeprom(0));

printf("\n\rDone\n\r");

while(1);
}
 


hello pcm programmer - I tried your code, but when compilng it I get an error "Undefined identifier -- write_eeprom" and the same for the read command
is there some include I need to put in my file, what am i missing here???
Ttelmah
Guest







PostPosted: Wed Mar 11, 2009 9:27 am     Reply with quote

I think the poster is confusing problem posts on the MicroChip forum, with errata...

There was quite a long thread a while ago, with a couple of people having problems with the early EEPROM locations on the Microchip forum. However it was almost certainly code, not the chips themselves. Have shipped now, something in 6 digits, of units containing the 877, using the EEPROM, and have used just about every silicon release, since the first engineering examples, and have never had an EEPROM problem on these chips.

You have to be slightly careful 'searching', and try using '87x', as well as '877', since some of the early erratas applied to all the 87x chips.

I'd try re-installing the compiler. Not finding internal functions, is a sure sign of a corrupted installation.

Best Wishes
guang cheng



Joined: 30 Nov 2009
Posts: 2

View user's profile Send private message Yahoo Messenger

PostPosted: Sun Sep 23, 2012 4:38 am     Reply with quote

I also have problem with EEPROM in 18F4580. I use the same code with you to write and read the data from EEPROM again. After I check this data written in EEPROM yet. I delete the code write to EEPROM then load it again to chip. Now, I read the value from that EEPROM address but it doesn't return the proper value. Thus, can you help me to fix this problem?
Here is my code:
First load:
Code:

write_eeprom(0,0x55);
int value;
value=read_eeprom(0);
printf(lcd_putc,"%d",value); 
delay_ms(1000);

Second load:
Code:

int value;
value=read_eeprom(0);
printf(lcd_putc,"%d",value); 
delay_ms(1000);

LCD appear: -1-1-1 and so on
_________________
Dui yi ge ren, ni shi shi ye!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 23, 2012 4:51 pm     Reply with quote

Quote:
I delete the code write to EEPROM then load it again to chip.

Most programmers (ICD2, Pickit2, ICD3, ICD-U40, etc.) have an option
to preserve the eeprom when programming the PIC. Read this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=38325&highlight=preserve+eeprom
guang cheng



Joined: 30 Nov 2009
Posts: 2

View user's profile Send private message Yahoo Messenger

PostPosted: Tue Sep 25, 2012 7:49 am     Reply with quote

Thank you very much for replying! I misunderstand between 2 functions: read/write from/to program memory and from/to eeprom.
_________________
Dui yi ge ren, ni shi shi ye!
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