View previous topic :: View next topic |
Author |
Message |
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
Witing to internal eeprom |
Posted: Wed Jan 17, 2007 8:28 am |
|
|
I would like to set some default values in the internal eeprom for a 18F2580 that would only be written when programming. Say for example I want to write 4 bytes starting at position zero.
It appears I need to use the #rom command. Would ROM use the zero based eeprom index like the other routines or something different.
byte bMyValues[4]
#rom 0xF00000 = {1,2,3,4} //I think F00000h is the eeprom start pos.
Is that correct address for the eeprom start position?
Afterwards, the program will read and write to to the eeprom via the normal methods.
From what I'm reading, reading and writing to the internal eeprom using the built in routines, my addresses start at 0 for the first address of the eeprom.
for (i=0;i<=4;++i)
{
Read_EEPROM(i, bMyValues[i]);
} |
|
|
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
|
Posted: Wed Jan 17, 2007 11:37 am |
|
|
It sure seems like they could update their help some and make it a little more complete.
Such as #ROM stores in 16 bits by default is not obvious in the help section.
I'm pretty sure I figured it out as it works using the ROM statement at the 0xF00000 address. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
|
Posted: Wed Jan 17, 2007 12:26 pm |
|
|
That is the exact post I ended up finding that helped me fix the problem.
Thanks. |
|
|
Guest
|
|
Posted: Wed Jan 17, 2007 6:04 pm |
|
|
Quote: | A few examples:
Code: | // Example to set words:
#ROM 0xF00000 = {1, 2, 3, 4, 5}
// Example to set bytes:
#ROM int8 0xF00000 = {1, 2, 3, 4, 5}
// Example to set a string of bytes:
#ROM 0xF00010 = {"12345"} |
|
(The above was copied from the thread referenced in an earlier post.)
This thread is timely as I was looking for info on the same thing. I have three 16-bit values and one 8-bit value that I'm loading into EEPROM at program time.
I coded it like this and it works fine -
Code: |
#rom 0xF00000 = {EEPROM_VAL_1, EEPROM_VAL_2, EEPROM_VAL_3}
#rom int8 0xF00006 = {EEPROM_CHECKSUM} |
Just curious but I never saw any documentation stating that the default size for the argument for the #rom directive was 16-bit. I plan to keep it as is but it's a little unnerving to do so without any documentation to back it up. Did I miss this being stated somewhere? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jan 17, 2007 6:11 pm |
|
|
Quote: |
Just curious but I never saw any documentation stating that the default
size for the argument for the #rom directive was 16-bit |
The CCS manual says the address refers to a word.
From the manual:
Quote: |
#ROM
Syntax: #rom address = {list}
Elements: address is a ROM word address
|
|
|
|
rwskinner
Joined: 08 Dec 2006 Posts: 125 Location: Texas
|
|
Posted: Wed Jan 17, 2007 6:50 pm |
|
|
PCM programmer wrote: | Quote: |
Just curious but I never saw any documentation stating that the default
size for the argument for the #rom directive was 16-bit |
The CCS manual says the address refers to a word.
From the manual:
Quote: |
#ROM
Syntax: #rom address = {list}
Elements: address is a ROM word address
|
|
You indeed are correct but it's must be easy to overlook because it has stumped numerous folks. Thanks to this forum I found my answer.
You all have to remember, that we're not all seasoned C folks. I'm not only learning a new language, but also a totally new compiler. It means a great deal to me that folks take the time to help. |
|
|
|