View previous topic :: View next topic |
Author |
Message |
simon630 Guest
|
how to store a static variable in the rom? |
Posted: Sun Sep 07, 2003 10:44 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Pete Guest
|
Re: how to store a static variable in the rom? |
Posted: Mon Sep 08, 2003 12:38 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
simon630
Joined: 07 Sep 2003 Posts: 17
|
|
Posted: Mon Sep 08, 2003 3:39 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
![](templates/subSilver/images/spacer.gif) |
Pete Guest
|
|
Posted: Mon Sep 08, 2003 6:55 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Mon Sep 08, 2003 7:37 pm |
|
|
thx. My pic is 16LF76, which does not have EEPROM DATA, then how? |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Sep 08, 2003 8:14 pm |
|
|
Read the FAQ I posted! |
|
![](templates/subSilver/images/spacer.gif) |
simon630
Joined: 07 Sep 2003 Posts: 17
|
|
Posted: Tue Sep 09, 2003 2:04 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Sep 09, 2003 6:15 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
simon630
Joined: 07 Sep 2003 Posts: 17
|
|
Posted: Wed Sep 10, 2003 3:24 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|