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

Variables in EEPROM

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



Joined: 02 Jan 2009
Posts: 8

View user's profile Send private message

Variables in EEPROM
PostPosted: Tue Feb 03, 2009 8:59 am     Reply with quote

Hi guys!

I'm working on a device where parameterizing should be possible.
Some variables should be in the non-volatile eeprom of the pic18f4550.
So I tried to define a memory region in the eeprom like it is done in the ccs_c_manual.pdf.

Code:
void DataEE_Read(int32 addr, int8 * ram, int bytes)
{
   int l;
   for(l=0;l<=bytes;l++,ram++,addr++)
   *ram=read_eeprom(addr);
}

void DataEE_Write(int32 addr, int8 * ram, int bytes)
{
   int l;
   for(l=0;l<=bytes;l++,ram++,addr++)
   write_eeprom(addr,*ram);
}
addressmod (DataEE,Data_EE_read,DataEE_write,0x00,0x10);


...so when I compile my source-file with this code in it I have no troubles.


But...When I add the following line to my main-procedure:
Code:
int8 DataEE i;

I get about a hundred errors starting with this one:
Code:
*** Error 36 "H:\Backups\Backup-Projekte\USB_Serial\my_usb_serial.c" Line 241(12,16): Expecting a ; or ,

...and when I double-Click it the cursor jumps into the line where the declaration of i happens!!

Why does it not work?
Is anybody able to help me?
Ttelmah
Guest







PostPosted: Tue Feb 03, 2009 10:48 am     Reply with quote

Big question - what compiler version.
Second comment though, 'beware'. The EEPROM, has relatively limited write life. Using it for variables, is not really a very good idea. The compiler buffers the read/writes through a local RAM buffer, and the code involved is quite large, so the only advantage of this approach, is when you want to deal with huge external arrays (tens of KB say), stored on an external medium. Otherwise you are much better off creating your own RAM copy, and initialising this from the EEPROM on boot, then only writing it on perhaps power failure, or if the values have been constant for several minutes.

Best Wishes
Tolorio



Joined: 02 Jan 2009
Posts: 8

View user's profile Send private message

PostPosted: Tue Feb 03, 2009 1:01 pm     Reply with quote

Okay...
I'm using the CCS V4.016 and MPLAB V8.10.

I know that the EEPROM has limited write life and I think I have expressed the problem in an unclear way.
The data that I want to store in the EEPROM is not used as variables in the source-code but as constants. They are never changed during the normal program flow, but there is a special mode (when the device is plugged via usb to the PC) where some constants should be changeable.

Doesn't it make sense to locate these variables (constants) directly in the EEPROM??

regards
Ttelmah
Guest







PostPosted: Tue Feb 03, 2009 3:18 pm     Reply with quote

4.016, is the problem. Read the sticky thread at the head of the forum, and you will see this is well before the point where more complex functions like addressmod started working.
Realistically, perfectly sensible to store the values in EEPROM, but even on a later compiler, don't use addressmod. Just copy them from EEPROM on boot, and write them back when needed. Smaller, and less likely to give problems.

Best Wishes
Tolorio



Joined: 02 Jan 2009
Posts: 8

View user's profile Send private message

PostPosted: Tue Feb 03, 2009 3:25 pm     Reply with quote

OK i will do...
Anyway, Thank you...
mayler



Joined: 13 Nov 2008
Posts: 10

View user's profile Send private message

PostPosted: Tue Feb 03, 2009 5:09 pm     Reply with quote

And try to update. This version is too bugged.
Guest








PostPosted: Tue Oct 27, 2009 8:38 am     Reply with quote

Ttelmah wrote:
4.016, is the problem. Read the sticky thread at the head of the forum, and you will see this is well before the point where more complex functions like addressmod started working.
Realistically, perfectly sensible to store the values in EEPROM, but even on a later compiler, don't use addressmod. Just copy them from EEPROM on boot, and write them back when needed. Smaller, and less likely to give problems.

Best Wishes

True!!
Addressmod or type mod are not working properly with arrays at version 4.093.

I'm creating a char array on fram, and I'm trying to change one element of this array but compiler changing 2 bytes from array. Only 16 bit variables writing normal. 32 or 8 bit array variables are sux. Reading working good for all. And any 8bit variables or 16bits are working good. But arrays are problematic.
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