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

Array's at FLASH-ROM

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







Array's at FLASH-ROM
PostPosted: Fri Oct 10, 2003 3:21 am     Reply with quote

I hope that somebody can help me with my problem:

I have some array's (CONST byte array[]) in my programm for 18F452/458 und use the PCH-Compiler (lastest version 3.178). Sometimes in my programm this could be:

test = array[23]; // get values from ROM

The compiler optimize this and use the value of array at compiling-time. The problem is that this parts of FLASH will be changed during runtime, so arrry[23] differs in runtime.

Do I have a chance to avoid this ??
My current solution isn't nice:
tmp4 = 23;
test = array[tmp4];

Sorry for my poor English.

Kind regards
Uwe
Mark



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

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

PostPosted: Fri Oct 10, 2003 6:16 am     Reply with quote

Check out read_program_eeprom(). If you locate the array, you should be able to use this function.
Ttelmah
Guest







PostPosted: Fri Oct 10, 2003 9:15 am     Reply with quote

Mark wrote:
Check out read_program_eeprom(). If you locate the array, you should be able to use this function.


Realistically, it is also worth considering using the internal EEPROM, rather than the main program memory, if this data is going to change more than once or twice. The 'life cycle' of the internal program memory, is far lower than that of the EEPROM (though both memories are 'EEPROM' in nature), and putting constant tables into the EEPROM, frees the program memory to hold code.
It is worth remembering that you can use the #define ability, to give a 'psuedo' array access nature to the EEPROM, with something like:
#define first_array (0)
#define second_array (20)
#define get_array(x,y) (int8)read_data_eeprom(x+y)

Then you can use code like:
get_array(first_array,4);
to read the fifth byte from the first array.

Best Wishes
brianj



Joined: 06 Oct 2003
Posts: 6
Location: Liverpool, UK

View user's profile Send private message

PostPosted: Sat Oct 11, 2003 5:46 am     Reply with quote

You could try the 'volatile' keyword.

volatile const char string[] = "HELLO" ;

x = string [0] ;

I haven't tried it in operation, but I can see from the assembler output that it's passing a parameter to a subroutine to get the first character rather than just using 'H'.

Brian
Mark



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

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

PostPosted: Sat Oct 11, 2003 8:42 am     Reply with quote

volatile is not used in CCS compiler. The array is declared as const which is the root of the problem.
Guest








PostPosted: Sat Oct 11, 2003 9:51 am     Reply with quote

>volatile is not used in CCS compiler

It is in the one I'm using (v3.177d)! Very Happy

volatile isn't mentioned in the help file, but the compiler accepts it without complaint and produces assembly output for the access to the constant in flash which looks like it could be re-reading the flash instead of using the value which was there at compile time.

Brian
brianj



Joined: 06 Oct 2003
Posts: 6
Location: Liverpool, UK

View user's profile Send private message

PostPosted: Sat Oct 11, 2003 9:53 am     Reply with quote

Sorry, the last post was from me (brianj). I forgot to log in. Embarassed

Brian
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