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

how to store a static variable in the rom?

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







how to store a static variable in the rom?
PostPosted: Sun Sep 07, 2003 10:44 pm     Reply with quote

hi, friends,
i would like to store our product id inside the rom code, say the first 2 addresses of the ROM. will i be able to do that? initially we are using the fram to store it. but sometimes corruption occurs. therefore we want to store it in a safer place.
thank you in advance.
Simon
Pete
Guest







Re: how to store a static variable in the rom?
PostPosted: Mon Sep 08, 2003 12:38 am     Reply with quote

simon630 wrote:
hi, friends,
i would like to store our product id inside the rom code, say the first 2 addresses of the ROM. will i be able to do that? initially we are using the fram to store it. but sometimes corruption occurs. therefore we want to store it in a safer place.
thank you in advance.
Simon


Yes, it's very easy to do. I personally store the information in the E2PROM of the devices.

Just use

#ROM 0x2100 = {0x12,0x34}

for the 12 and 16 series devices.

You can then read the data (if you want!) using read_eeprom(0); and read_eeprom(1);

Hope this helps,

Pete.
simon630



Joined: 07 Sep 2003
Posts: 17

View user's profile Send private message

PostPosted: Mon Sep 08, 2003 3:39 am     Reply with quote

thanks. then how about #ROM taking in variable instead of constant as its parameters? what i mean is sth like #ROM 0x2100={buf[0], buf[1]}
i understand that #ROM is expecting a constant parameters. but i am just wondering whether certain way could achieve it.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Placing data in a CONST array
PostPosted: Mon Sep 08, 2003 5:34 am     Reply with quote

Read this FAQ and you will find your answer1

http://www.ccsinfo.com/faq/?19
Pete
Guest







PostPosted: Mon Sep 08, 2003 6:55 am     Reply with quote

simon630 wrote:
thanks. then how about #ROM taking in variable instead of constant as its parameters? what i mean is sth like #ROM 0x2100={buf[0], buf[1]}
i understand that #ROM is expecting a constant parameters. but i am just wondering whether certain way could achieve it.


#ROM is compile time only.

If you want to write the current code version to E2PROM, you can use write_eeprom(buf[0],0); etc.

HTH

Pete.
Guest








PostPosted: Mon Sep 08, 2003 7:37 pm     Reply with quote

thx. My pic is 16LF76, which does not have EEPROM DATA, then how?
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Sep 08, 2003 8:14 pm     Reply with quote

Read the FAQ I posted!
simon630



Joined: 07 Sep 2003
Posts: 17

View user's profile Send private message

PostPosted: Tue Sep 09, 2003 2:04 am     Reply with quote

thx, Mark. after reading the Faq, i thought it is not answering my question.
what i want to store in the ROM is not constant actually. it is a user input string (eg. the serial no of this device) that the pic reads from its rx pin.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Sep 09, 2003 6:15 am     Reply with quote

If you don't have eeprom on the chip then you are out of luck. I would look into why the corruption occurs. It shouldn't. Maybe something is overwriting it. You might try storing it in 2 locations and maybe including a checksum. You might also verify the data once it is written.
simon630



Joined: 07 Sep 2003
Posts: 17

View user's profile Send private message

PostPosted: Wed Sep 10, 2003 3:24 am     Reply with quote

oh. the ram part i am using now is 24cl64 from Ramtron. the data in the first few addresses tends to be corrupt quite easily. i am not sure whether other friends encounter this b4. this chip did provide a WP option, but unfortunately our product runs out of i/o pin. therefore we ties it to ground so that write protect is disabled. and the second important reason is the data going to be stored is the serial no., which is unique and important. i am afraid it may do harm to the society if the s/n corrupts.
i ever thought of using ROM 0010={sn1, sn2}. sn1 and sn2 are constant. to program into the program flash. but comes to production, it will be very difficult as the operator may need to compile the code every time the serial number is changed.
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