Page 1 of 1
RAM and ROM
Posted: Mon Apr 07, 2008 3:36 pm
by Ondra
Good day all.
I wrote this program using a lot of string manipulations. When I tried to compiled it. My RAM use was way over and my ROM use was 0. Where can I get more information on the effective use of RAM and ROM when building my program. I searched this forum with no luck.
Ondra
Re: RAM and ROM
Posted: Mon Apr 07, 2008 4:00 pm
by Benj
Hello Ondra
You can create an array or string that goes straight into the program memory by using the rom command.
rom char* ASCII1 = {0x00 , 0x00 , 0x00 , 0x00 , 0x00 , // 32 = <space>
0x00 , 0x06 , 0x5F , 0x06 , 0x00 , // 33 = !
0x07 , 0x03 , 0x00 , 0x07 , 0x03 , // 34 = "
0x24 , 0x7E , 0x24 , 0x7E , 0x24 , // 35 = #
0x24 , 0x2B , 0x6A , 0x12 , 0x00 , // 36 = $
0x63 , 0x13 , 0x08 , 0x64 , 0x63 , // 37 = %
0x36 , 0x49 , 0x56 , 0x20 , 0x50 , // 38 = &
0x00 , 0x07 , 0x03 , 0x00 , 0x00 , // 39 = '
0x00 , 0x3E , 0x41 , 0x00 , 0x00 , // 40 = (
0x00 , 0x41 , 0x3E , 0x00 , 0x00 , // 41 = )
0x08 , 0x3E , 0x1C , 0x3E , 0x08 , // 42 = *
0x08 , 0x08 , 0x3E , 0x08 , 0x08}; // 43 = +
Here it is used to store 60 byte values. I think that there is a maximum size you can use so you can always declare multiple arrays of data.
As the data is a C code variable you will either have to copy the variable a byte at a time into a Flowcode variable.
eg
FCV_TEMP = ASCII1[0];
All of this operation should be detailed in the BoostC manual that is available from the Flowcode V3/BoostC directory.
Re: RAM and ROM
Posted: Mon Apr 07, 2008 7:30 pm
by Ondra
Ok Benj. You've raised the bar a little too high too soon. I looked at the BoostC manual. Is there an easier way? Not so much the writing to ROM part, but a more efficient way of putting together a program that saves on RAM use. What if any are the things I should be considering as far as RAM is concerned, when building the program.
Ondra
Re: RAM and ROM
Posted: Mon Apr 07, 2008 9:05 pm
by Steve
I've got a few suggestions:
* use BYTEs instead of INTs wherever possible
* keep arrays as small as possible (if you can)
* if using strings, try to allocate a smaller amount of memory to them (e.g. MyString[10])
* don't use variables for constant values
* use hardcoded strings in the program memory
Unfortunately, the current version of Flowcode does not let you use constants as you would variables. This will change.
Re: RAM and ROM
Posted: Tue Apr 08, 2008 10:21 am
by Ondra
Got it. Thanks Steve.