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

Program internal EEPROm

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



Joined: 22 Dec 2003
Posts: 82

View user's profile Send private message

Program internal EEPROm
PostPosted: Mon May 17, 2004 1:39 pm     Reply with quote

Hi,

I have parameters file of 256 Bytes, that I want to program to the 16F877.
What is the recommended way to program the internal EEPROM from the C code. (I can't use RS232 to transfer the file).

Edi
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 17, 2004 6:01 pm     Reply with quote

Quote:
I have parameters file of 256 Bytes, that I want to program to the
16F877. What is the recommended way to program the internal
EEPROM from the C code.


Use a #rom statement, with the starting address at 0x2100.
This address is the start address of the on-chip EEPROM for the 16F877.
Example of how to put a string in EEPROM:

#rom 0x2100 = {"Hello there"}

Example of how to put data bytes in EEPROM:
#rom 0x2100 = {0x01, 0x02, 0x03 }

Put the #rom statement above main(). After you compile the file,
open the EEPROM window in MPLAB. You should see the data there.
---------

Edited on 5-18-04 to put the entire string in quotes, instead of using
single quotes on each character. The newer versions of the CCS
compiler now allow you do this. Also added a separate example
which shows how to put bytes in EEPROM.


Last edited by PCM programmer on Tue May 18, 2004 1:25 am; edited 1 time in total
djpark



Joined: 02 Mar 2004
Posts: 49

View user's profile Send private message

PostPosted: Tue May 18, 2004 1:02 am     Reply with quote

PCM programmer wrote:
Use a #rom statement, with the starting address at 0x2100.
This address is the start address of the on-chip EEPROM for the 16F877.
Example of how to put a string in EEPROM:

#rom 0x2100 = {'H','E','L','L','O',' ','T','H','E','R','E'}


Is the start address of eeprom different from PIC to PIC? If so, what is a general way to find out the address within the program execution?

-- dj
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 18, 2004 1:45 am     Reply with quote

Quote:
Is the start address of eeprom different from PIC to PIC ?
If so, what is a general way to find out the address within the program
execution?

I haven't checked the data sheet for every PIC, so I don't know
how many different addresses they use. I do know that the 16F877
(etc.) and the 16F628 use 0x2100. The 18F452 and 18F458 use
0xF00000.

To find the address, you can look in the Programming specification
document for each PIC. In the modern documents, they have a
section in the back, titled "Embedding Data EEPROM Information in
the HEX File", or something similar. That section has the address.
In earlier Programming Specification documents, the address may
be in the section on "Data EEPROM Memory", or it might be somewhere
else in the document.

The Microchip website appears to be down at the moment I'm writing
this, so I can't give you a link to the page that has the programming
specifications.
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Tue May 18, 2004 7:52 am     Reply with quote

djpark wrote:
PCM programmer wrote:
Use a #rom statement, with the starting address at 0x2100.
This address is the start address of the on-chip EEPROM for the 16F877.
Example of how to put a string in EEPROM:

#rom 0x2100 = {'H','E','L','L','O',' ','T','H','E','R','E'}


Is the start address of eeprom different from PIC to PIC? If so, what is a general way to find out the address within the program execution?

-- dj


From program execution the address of the first byte is 0. The 0x2100 address only applies to compile time for the purpose of preloading the EEPROM during programming.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Tue May 18, 2004 10:19 am     Reply with quote

Thanks PCM programmer. I've always wondered how to do this. Very Happy
edi



Joined: 22 Dec 2003
Posts: 82

View user's profile Send private message

PostPosted: Wed May 19, 2004 12:54 pm     Reply with quote

Thanks you all.

Edi
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