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

Problem with embedding EEPROM data in source code

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







Problem with embedding EEPROM data in source code
PostPosted: Tue Apr 08, 2003 5:10 am     Reply with quote

Hi,

I'd like to embed my EEPROM data within the source code to generate a hex file so I can program firmware and configuration into my 18F242 in one go.

Unfortunately, using this line:

#rom 0xF00000 = {1,2,3,4,5,6,7}

creates the following in the EEPROM view window within MPLAB:

Address 00 01 02 03 04 05 06 07 etc
-------------------------------
0000 01 00 02 00 03 00 04 etc

It seems that each value within the curly brackets is regarded as a 16bit value rather than a byte which is really what I need.

Writing #rom 0xF00000 = {0x0201,etc } works and uses the odd EEPROM locations but my configuration data is difficult to edit this way as the bytes are not in order.

Is this normal or a bug?

Any feedback appreciated. Thanks.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13486
Michi
Guest







Re: using PCH V3.150 / MPLAB 6.13.0.0
PostPosted: Tue Apr 08, 2003 5:36 am     Reply with quote

<font face="Courier New" size=-1>Forgot to mention I use PCH V3.150 and MPLAB 6.13.0.0 with latest CCS MPLAB-plugin.</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 13488
R.J.Hamlett
Guest







Re: Problem with embedding EEPROM data in source code
PostPosted: Tue Apr 08, 2003 6:13 am     Reply with quote

:=Hi,
:=
:=I'd like to embed my EEPROM data within the source code to generate a hex file so I can program firmware and configuration into my 18F242 in one go.
:=
:=Unfortunately, using this line:
:=
:=#rom 0xF00000 = {1,2,3,4,5,6,7}
:=
:=creates the following in the EEPROM view window within MPLAB:
:=
:=Address 00 01 02 03 04 05 06 07 etc
:=-------------------------------
:= 0000 01 00 02 00 03 00 04 etc
:=
:=It seems that each value within the curly brackets is regarded as a 16bit value rather than a byte which is really what I need.
:=
:=Writing #rom 0xF00000 = {0x0201,etc } works and uses the odd EEPROM locations but my configuration data is difficult to edit this way as the bytes are not in order.
:=
:=Is this normal or a bug?
:=
:=Any feedback appreciated. Thanks.
Remember the memory 'model' for the programmer, is 16bits wide on the PIC18 family. The data stored is in 'words', which are therefore 16bits long. This didn't matter on the smaller chips, but on the 18 chips, implies that each element between the commas, can store two bytes. Hence if you want to store two bytes, you need to put them together into one 16bit word. Unfortunately (as you have found), putting the data together makes it rather less obvious, and harder to edit...
Fortunately, there is a 'trick' method of making it work. The following syntax, allows individual bytes to be stored in the EEPROM:
#rom int8 0xF00000 = { 0x00 }
#rom int8 0xF00001 = { 0x01 }
#rom int8 0xF00002 = { 0x02 }
#rom int8 0xF00003 = { 0x03 }

or the method I use is to declare a macro, which allows an address, and a value to be specified as:

#define EEPROM 0xF00000
#define EBYTES(x,y) #ROM EEPROM+x = { y }

EBYTES(0,0)
EBYTES(1,1)
EBYTES(2,4)
EBYTES(3,6)

Which will store '0' to the first address (0), '1' to the second address, 4 to the third, and 6 to the fourth.

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 13491
Michi
Guest







Re: Problem with embedding EEPROM data in source code
PostPosted: Tue Apr 08, 2003 11:49 am     Reply with quote

Many thanks for your helpful tips. Definately much easier to edit it with your examples.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13505
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