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

Witing to internal eeprom

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



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

Witing to internal eeprom
PostPosted: Wed Jan 17, 2007 8:28 am     Reply with quote

I would like to set some default values in the internal eeprom for a 18F2580 that would only be written when programming. Say for example I want to write 4 bytes starting at position zero.

It appears I need to use the #rom command. Would ROM use the zero based eeprom index like the other routines or something different.

byte bMyValues[4]


#rom 0xF00000 = {1,2,3,4} //I think F00000h is the eeprom start pos.

Is that correct address for the eeprom start position?

Afterwards, the program will read and write to to the eeprom via the normal methods.

From what I'm reading, reading and writing to the internal eeprom using the built in routines, my addresses start at 0 for the first address of the eeprom.

for (i=0;i<=4;++i)
{
Read_EEPROM(i, bMyValues[i]);
}
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

PostPosted: Wed Jan 17, 2007 11:37 am     Reply with quote

It sure seems like they could update their help some and make it a little more complete.

Such as #ROM stores in 16 bits by default is not obvious in the help section.

I'm pretty sure I figured it out as it works using the ROM statement at the 0xF00000 address.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 17, 2007 11:46 am     Reply with quote

Most of this stuff is in the archives. See the last post in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=25522&highlight=rom+0xf00000+int8
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

PostPosted: Wed Jan 17, 2007 12:26 pm     Reply with quote

That is the exact post I ended up finding that helped me fix the problem.

Thanks.
Guest








PostPosted: Wed Jan 17, 2007 6:04 pm     Reply with quote

Quote:
A few examples:
Code:
// Example to set words:
#ROM 0xF00000 = {1, 2, 3, 4, 5}

// Example to set bytes:
#ROM int8 0xF00000 = {1, 2, 3, 4, 5}

// Example to set a string of bytes:
#ROM 0xF00010 = {"12345"}


(The above was copied from the thread referenced in an earlier post.)

This thread is timely as I was looking for info on the same thing. I have three 16-bit values and one 8-bit value that I'm loading into EEPROM at program time.

I coded it like this and it works fine -
Code:

#rom      0xF00000 = {EEPROM_VAL_1, EEPROM_VAL_2, EEPROM_VAL_3}
#rom int8 0xF00006 = {EEPROM_CHECKSUM}


Just curious but I never saw any documentation stating that the default size for the argument for the #rom directive was 16-bit. I plan to keep it as is but it's a little unnerving to do so without any documentation to back it up. Did I miss this being stated somewhere?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 17, 2007 6:11 pm     Reply with quote

Quote:

Just curious but I never saw any documentation stating that the default
size for the argument for the #rom directive was 16-bit

The CCS manual says the address refers to a word.

From the manual:
Quote:

#ROM
Syntax: #rom address = {list}
Elements: address is a ROM word address
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

PostPosted: Wed Jan 17, 2007 6:50 pm     Reply with quote

PCM programmer wrote:
Quote:

Just curious but I never saw any documentation stating that the default
size for the argument for the #rom directive was 16-bit

The CCS manual says the address refers to a word.

From the manual:
Quote:

#ROM
Syntax: #rom address = {list}
Elements: address is a ROM word address


You indeed are correct but it's must be easy to overlook because it has stumped numerous folks. Thanks to this forum I found my answer.

You all have to remember, that we're not all seasoned C folks. I'm not only learning a new language, but also a totally new compiler. It means a great deal to me that folks take the time to help.
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