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

Initializing EEPROM

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



Joined: 22 Aug 2008
Posts: 21

View user's profile Send private message

Initializing EEPROM
PostPosted: Fri Mar 16, 2012 9:39 am     Reply with quote

Hi
I want to set parameters in EEPROM while programming the micro.
I've tried using #rom adress={,} but I can't make it work.
After compiling and downloading the code the EEPROM windows continue to show me the previous data. nothing as changed.

The processor is PIC18F2525
Uses MPLAB V8.8 and a PicKit2
Compiler 4.071

Since I'm not sure about the address, does anyone know what it is and where to find it?
BTW: where in the 18F2525 spec sheet can I find this address?

thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19328

View user's profile Send private message

PostPosted: Fri Mar 16, 2012 9:43 am     Reply with quote

Don't bother!....
Let the compiler do it for you Smile :

#rom getenv("EEPROM_ADDRESS")={,}

It is in the _programming specification_ sheet, but letting the compiler put it in for you is much safer and easier.

Best Wishes
JacquesB



Joined: 22 Aug 2008
Posts: 21

View user's profile Send private message

PostPosted: Fri Mar 16, 2012 11:50 am     Reply with quote

Thanks Ttelmah,

I'm not very familiar with all this but, I just tried it with a very simple program and I get:

--- Info 300 "test.c" Line 9(0,1): More info: Segment at 00000-00008 (000A used) Priv
--- Info 300 "test.c" Line 9(0,1): More info: Segment at 0000A-0BFFE (0000 used)
--- Info 300 "test.c" Line 9(0,1): More info: Attempted to create: 00000-00002 for reset
*** Error 126 "test.c" Line 9(0,1): Invalid ORG range

The code is :
Code:

#define DEBUG               

#include <18F2525.h>
#rom getenv("EEPROM_ADDRESS")={1,2,3,4,5}

void main(void){
while(1);
}

What am I doing wrong?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 16, 2012 12:30 pm     Reply with quote

Quote:
#rom getenv("EEPROM_ADDRESS")={1,2,3,4,5}

Your version has a bug. It returns an address of 0, which is incorrect.
So you have to do it with a direct address in the #rom statement.
Example:
Code:
#rom 0xF00000={1,2,3,4,5}


Here is how to find the data eeprom address:
Go to Google and search for your PIC, just like this:
Quote:

PIC18F2525

It must have the "PIC" in front of the number.

The first hit from Google will take you to the webpage for that PIC:
http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010278
On that page, scroll down to you get to the "Programming Specification"
document and download it.

Then look for this section:
Quote:

5.5 Embedding Data EEPROM
Information In the HEX File

That section will tell you the address of the PIC's internal eeprom.
You can find it this way for any PIC.

Normally the getenv() method works, but when CCS newly releases
support for a PIC, they are quite often sloppy about entering the data
into the Device Database. It can take them a few versions to get it
all correct.
JacquesB



Joined: 22 Aug 2008
Posts: 21

View user's profile Send private message

Initializing EEprom from MPlab
PostPosted: Fri Mar 16, 2012 2:02 pm     Reply with quote

Thanks for taking time to show me where to find the information.

I would never have found this info in a programming sheet. I was looking in the spec sheet!

It works (after figure out to check "Clear EE Data upon loading a program" in config/settings/program loading).

I'm going to have a good weekend thanks to you.

Is there a way to change the way the compiler will fill the words (MSB, LSB) instead of (LSB,MSB) ?
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