|
|
View previous topic :: View next topic |
Author |
Message |
aldinlapinig
Joined: 16 Dec 2005 Posts: 22
|
Assigning values to an array... |
Posted: Sat Jul 07, 2007 7:42 pm |
|
|
Hi all,
how can u assign hex values to an array?
is the ff. code valid?
Code: | int myArray[30];
myArray = 0x01,0x02,0x03,0x04 ... 0x1E;
|
how do u do it?
thanx...
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Jul 07, 2007 9:53 pm |
|
|
See this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=29142
Also, when you have a series of questions on a certain topic
such as arrays, you can post your question to the existing thread.
You don't have to start a new thread each time. |
|
|
aldinlapinig
Joined: 16 Dec 2005 Posts: 22
|
Thanx... |
Posted: Sun Jul 08, 2007 6:09 am |
|
|
thank you very much PCM programmer. i looked at the link that you gave me but is there another way of assigning values to the array without declaring another array as constant? My purpose is to save RAM. I have so much data to send out from the PIC. I want to do it using arrays instead of having a long series of PUTC's in my program. Thank you so much for your immediate response. It is highly appreciated.
-=alDin=- |
|
|
Ttelmah Guest
|
|
Posted: Sun Jul 08, 2007 9:29 am |
|
|
At the end of the day, the values have to be stored somewhere...
You can declare an array at initialisation, with the standard:
int array[10] = {1,2,3,4,5,6,7,8,9,10};
Using hex values, but the compiler will still effectively generate a constant array, and just automatically copy it to RAM for use at the start of the code.
Declaring a number of constant arrays, and copying just the one you want to RAM when needed, allows a single RAM area to be used, rather than multiple areas, but obviously the constant arrays have to exist to hold the values. They only use ROM though, not RAM.
Best Wishes |
|
|
|
|
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
|