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

internal EEPROM read/write and Code Protection CPD WRTD

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



Joined: 18 Sep 2012
Posts: 2

View user's profile Send private message

internal EEPROM read/write and Code Protection CPD WRTD
PostPosted: Tue Sep 18, 2012 12:22 pm     Reply with quote

I'm trying to use the internal data EEPROM to store a serial number.

I use the write_eeprom() and read_eeprom() commands to read and write bytes and it works fine.

However, when I clear the CPD and WRTD configuration bits (0=write protection enabled), the program cannot write or read as before.

According to the Microchip datasheet ( PIC18F86K22_39960d.pdf ) this should still work though:

"Data EEPROM memory has its own code-protect bits in
the Configuration Words. External read and write
operations are disabled if code protection is enabled.
The microcontroller itself can both read and write to the
internal data EEPROM, regardless of the state of the
code-protect Configuration bit.
"

Any idea anyone?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 18, 2012 12:36 pm     Reply with quote

Your quote is referring to the CPD config bit. But you are also clearing
(ie, enabling) the WRTD bit. The 18F86K22 data sheet says that WRTD
prevents the PIC from writing to its internal data eeprom:
http://ww1.microchip.com/downloads/en/DeviceDoc/39960d.pdf
Quote:

28.6.2 DATA EEPROM CODE PROTECTION

The entire data EEPROM is protected from external
reads and writes by two bits: CPD and WRTD. CPD
inhibits external reads and writes of data EEPROM.
WRTD inhibits internal and external writes to data
EEPROM. The CPU can always read data EEPROM
under normal operation, regardless of the protection bit
settings.
cformer



Joined: 18 Sep 2012
Posts: 2

View user's profile Send private message

PostPosted: Wed Sep 19, 2012 7:51 am     Reply with quote

Thank you very much PCM programmer!

That fixed it. I hadn't spotted the other paragraph you quoted, and the one I was referring to was not really clear (to me anyway, proven by my misinterpretation).
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