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

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



Joined: 30 Jan 2007
Posts: 56
Location: Viana do Castelo - Portugal

View user's profile Send private message

EEPROM
PostPosted: Tue Mar 24, 2009 8:44 am     Reply with quote

Hi

How can put eeprom data in the program code.
the hex file have after compiling?

Thanks
Ttelmah
Guest







PostPosted: Tue Mar 24, 2009 9:17 am     Reply with quote

How about using the search engine?
You can't add a hex file after compiling, except to load it separately into your programmer. You can include any data you want into the EEPROM, with the #ROM statement. A search here will tell you how to do it.

Best Wishes
AsmallGuy
Guest







PostPosted: Wed Apr 01, 2009 6:22 am     Reply with quote

I can give you some hints:

_first, try to find the address of the EEPROM locations for your specific PIC, example a PIC16F684 has it starting from 0x2100 up to 0x21FF (guess, 256 storage bytes)

_second:

Code:

#define my_storage 0x2100  // starting address

#rom my_storage={0x0F}  //  actual row to embed EEPROM in .hex file


Here you assign the value 0x0F to the location; you can add elements with commas; remember, you can ONLY STORE BYTEs, like 8-bits, no native approach to complex data type..

_third:

Code:

variable=read_EEPROM (my_storage);


Here it is, enough to start Wink
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 01, 2009 11:22 am     Reply with quote

Quote:
#define my_storage 0x2100

variable=read_EEPROM (my_storage);

This is not correct. The read_eeprom() function does not take the
hardware programming address of the eeprom as a parameter.
For a PIC that has 256 bytes of eeprom, the address used with
read_eeprom() should be in the range 0x00 to 0xFF.

This is stated in the manual:
Quote:
read_eeprom()

Syntax: value = read_eeprom (address)
Parameters: address is an (8 bit or 16 bit depending on the part) int
Returns: An 8 bit int
Function: Reads a byte from the specified data EEPROM address.
The address begins at 0 and the range depends on the part.

http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
AsmallGuy
Guest







PostPosted: Thu Apr 02, 2009 4:18 am     Reply with quote

Really?.. i wrote this test program using for my 16F684 (i've used also flex_lcd.c to see directly from the PIC):

Code:

#define low 0x2100
#define hig 0x2101

//#rom low={0x0F} disabled, no forced initialization
//#rom hig={0x0F}

int8 lowv=0;
int8 higv=0;

int16 pwm1=400;

...cut...

lowv=pwm1;
higv=(pwm1>>8);

write_eeprom(low,lowv);
write_eeprom(hig,higv);

lowv=higv=0;
 
lowv=read_EEPROM (low);
higv=read_EEPROM (hig);

pwm1=make16(higv,lowv);
   
printf(lcd_putc,"\fN1: %u N2: %u\nPwm: %Lu",higv,lowv,pwm1);

...


I'm seeing values: "1" and "144" and "400" which are correctly saved and retrieved from the EEPROM.

Could all this work only by chance of lucky numbers/addresses? i'm going to debug more and try so! can you replicate that in your environment?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 02, 2009 10:22 am     Reply with quote

Quote:
Could all this work only by chance of lucky numbers/addresses ?

That is correct. You are giving a 16-bit address to the read_eeprom()
function. It only uses the lower 8-bits. It throws away any upper bytes
that you give it. So it's working in spite of your error.
AsmallGuy
Guest







PostPosted: Fri Apr 03, 2009 2:02 am     Reply with quote

PCM programmer wrote:

That is correct. You are giving a 16-bit address to the read_eeprom()
function. It only uses the lower 8-bits. It throws away any upper bytes
that you give it. So it's working in spite of your error.


Ta-da! there we are :D - i'm getting used to this kind of approach!
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