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

an optimisation problem

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







an optimisation problem
PostPosted: Fri Aug 21, 2009 12:59 pm     Reply with quote

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

View user's profile Send private message AIM Address

they have a name for it-
PostPosted: Fri Aug 21, 2009 6:59 pm     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Fri Aug 21, 2009 8:27 pm     Reply with quote

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
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