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

EEPROM Address

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



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

EEPROM Address
PostPosted: Tue Nov 15, 2011 8:44 am     Reply with quote

18F2620
3.249

To address the EEPROM in the read and write_eeprom functions do I just use the 0x00 to 0x3FF addresses? It's been a while since I've done this and in my research I've found some conflicting info.

EDIT: Just thought to look at the CCS manual, it gives the address as an 8bit number. Kind of tough to address 1024 locations with 8bits?

EDIT2: Looks like they changed the verbiage in later manuals, 8 OR 16bit value depending on part.

Looks like I've got my answer. Just use 0x00 to 0x3FF. Anyone want to confirm?

Thanks,

John
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Tue Nov 15, 2011 9:56 am     Reply with quote

0x000 to 0x3ff is correct. The exception is when you want to preload the EEPROM with data at programming time.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Tue Nov 15, 2011 9:13 pm     Reply with quote

Thanks.

I had seen that and that was part of the confusion. I also had some old code that used the wrong approach but worked.

John
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Thu Nov 17, 2011 10:04 am     Reply with quote

Now I'm trying to program some EEPROM locations prior to run-time. I want to make sure this is the right address. The Programming Spec says:

Quote:
5.5 Embedding Data EEPROM
Information In the HEX File
To allow portability of code, a PIC18F2XXX/4XXX
family programmer is required to read the data
EEPROM information from the hex file. If data
EEPROM information is not present, a simple warning
message should be issued. Similarly, when saving a
hex file, all data EEPROM information must be
included. An option to not include the data EEPROM
information may be provided. When embedding data
EEPROM information in the hex file, it should start at
address, F00000h.


So, to put 0xFF in location 0x00 I would:

Code:
#rom 0xF00000 = {0xFF}



Thanks,

John
Ttelmah



Joined: 11 Mar 2010
Posts: 19477

View user's profile Send private message

PostPosted: Thu Nov 17, 2011 10:46 am     Reply with quote

It is correct, but the easiest/safest way, is to use the compiler!...
Code:

#ROM getenv("EEPROM_ADDRESS") = {0,20,60,45,19,28}


This way if you change chip in the future, you don't have to recalculate the address.

Best Wishes
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Thu Nov 17, 2011 1:25 pm     Reply with quote

Also be careful with the size of the data written to the EEPROM. I remember a project where I was expecting bytes out of the preprogrammed EEPROM but the compiler loaded it as if the data was int16's.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Fri Nov 18, 2011 6:17 pm     Reply with quote

Thanks for the info. I had seen the getenv in another post and had assumed it was v4 unique. I'll look and see if it is v3 friendly and use it.

I just spent all morning trying to find an addressing problem. I was using int8s in some calculations for address offsets. Only took me about 5 hours to figure out I had to cast them to int16s.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sat Nov 19, 2011 2:03 pm     Reply with quote

newguy wrote:
Also be careful with the size of the data written to the EEPROM. I remember a project where I was expecting bytes out of the preprogrammed EEPROM but the compiler loaded it as if the data was int16's.
At least in the v3 compilers the default was to write int16.

Code:
Example to set words (default):
  #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"}
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Sat Nov 19, 2011 5:35 pm     Reply with quote

ckielstra wrote:
At least in the v3 compilers the default was to write int16.


I just checked the manual. Yup, default is words. Thanks for that info, that would have eaten a good chunk of my life trying to find.
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