View previous topic :: View next topic |
Author |
Message |
18F runner Guest
|
an optimisation problem |
Posted: Fri Aug 21, 2009 12:59 pm |
|
|
Hi I am using 18F4620 mcu 64K rom, 3K ram
I have a huge ROM data aproximately 20K in structs.
I am writing to ROM database using rs232. UI interface asks to enter data for a specific struct. for example:
Code: |
for(number of cars){
printf(" please enter %dth cars wheel brand: ", i);
read( struct_car[i].wheelBrand );
writeIntoRom(structCarROM,struct_car);
}
for(number of cars){
printf(" please enter %dth cars model: ", i);
read( struct_car[i].model );
writeIntoRom(structCarROM,struct_car);
}
// same for house structs,
// and about 100 unique string readings from rs232 into RAM then ROM
|
The problem is while data printing to rs232 I use printf and printf takes
very much memory.
Is there a optimisation method for printf?
Here are some printf strings:
"Please enter number of Cars"
"Please enter number of Houses"
"Please enter number of Schools"
"Please enter name of electricity company"
"Please enter name of spoken languages"
and other 100s of strings. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
they have a name for it- |
Posted: Fri Aug 21, 2009 6:59 pm |
|
|
yes - I usually call what you seek - "EXTERNAL MEMORY"
addressed by: SPI , I2C or parallel
read: in blocks - terminated with \0
and all you do is call a suitable index value or if always read in the same sequence , simply delimited by \0 as a stream,
and you put an MT string to mark EOF as \0\0
put all that canned string prompt stuff outside the pic
and
you could creatively stream your response data to another ext EEPROM
(or static ram if it is transient) using the same principles. |
|
|
Jerson
Joined: 31 Jul 2009 Posts: 125 Location: Bombay, India
|
|
Posted: Fri Aug 21, 2009 8:27 pm |
|
|
If there are a number of "Please enter" type of strings, why not have just 1 of them and build the string? It might be lighter on the code.
Code: |
const char msg_PlsEnter[] = {"Please Enter "};
const char msg_TheNumber[]= {"the number of "};
|
And use it like this
Code: |
printf(msg_PlsEnter);
printf(msg_TheNumber);
printf("Statements like these\n");
|
A little cumbersome to code, but, it will save your ROM space.
Just an idea. _________________ Regards
Jerson Fernandes |
|
|
|