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 support@ccsinfo.com

out of rom!!

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



Joined: 03 Nov 2011
Posts: 7

View user's profile Send private message

out of rom!!
PostPosted: Thu Nov 03, 2011 6:07 am     Reply with quote

Hi, I'm developing a firmware for a pic 18F252, and I'm out of rom.

The thing is, that the firmware use a lot of printf and lcd_putc. I managed to use only a few functions to print the info.

Do you have some tips and tricks to compress the code?

If I define global variables, this variables use ROM space?
If I define them as local function variables, this variables use RAM instead of rom???

thanks!
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Thu Nov 03, 2011 8:52 am     Reply with quote

Have you tried searching for posts on this subject? There are boat-loads of threads regarding this.

Ronald
temtronic



Joined: 01 Jul 2010
Posts: 9171
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Nov 03, 2011 10:06 am     Reply with quote

By their nature ALL variables are stored in RAM.
If defined 'globally' the RAM locations where the data is stored only gets used for that unique purpose.
If 'locally' defined, then RAM is used, as required, by whatever functions or operations require RAM.
How you configure or utilize RAM is dependent upon how you cut code. 'local' RAM will be 'reused' as required, 'global' for one variable. PICs with lots of RAM allow programmers to get 'sloppy' and less efficient in overall code cutting.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 03, 2011 3:15 pm     Reply with quote

See this thread. It has 8 links to threads that discuss the "Out of Rom"
problem, with solutions:
http://www.ccsinfo.com/forum/viewtopic.php?t=43849
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Fri Nov 04, 2011 3:28 am     Reply with quote

PCM programmer wrote:
See this thread. It has 8 links to threads that discuss the "Out of Rom"
problem, with solutions:
http://www.ccsinfo.com/forum/viewtopic.php?t=43849


One of those links says that "printf and lcd_putc" hog rom as they are particularly code size inefficient. Your code has "a lot" of them....

When you're out of rom then essentially your code has got too big and/or too complicated. Instead of taking forever to slim it down, the best solution, and the one which gives you a future upgrade path, is often simply to get a bigger PIC.

RF Developer
Steam



Joined: 03 Nov 2011
Posts: 7

View user's profile Send private message

PostPosted: Fri Nov 04, 2011 5:41 am     Reply with quote

Thanks for the answer, i will take a look at the thread.

I cant use a bigger pic because its an upgrade for an existing product, so i cant change anything in the hardware, just an upgrade on the firmware.

thanks!
temtronic



Joined: 01 Jul 2010
Posts: 9171
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Nov 04, 2011 6:03 am     Reply with quote

Sounds like you fallen for the 'spare a few pennies, don't use a socket for the PIC' problem.Decades ago I learned to socket most ICs, especially the PIC. I know, too late now but in the future, consider the overall cost savings.
Seems bigger( more features,more ROM,RAM,etc) but pin compatible PICS are arriving every week unlike 2 decades ago making it hard to properly choose or 'keep up'.It'll cost less than a buck now to save 10s or 100s down the road when the 'feature creep' comes,it always does.

In your case, I'd print the entire listing and highlight potential code that is common and turn into functions.Perhaps there's redundant code( same stuff in several functions) that can be eliminated.Reorganizing variables(more local, less global ) might trim a few bytes here and there.
Maybe you've got same or similar code in 'header' files that are also in 'main'.Look for multiple 'defines' or similar lines of code.

I find looking at the program on paper,getting the whole picture, can show obvious,'why did I do that !' stuff quickly.

Shaving a few bytes here, some more there does add up and you might be able to squeeze in what you need, but it'll take time.
dyeatman



Joined: 06 Sep 2003
Posts: 1924
Location: Norman, OK

View user's profile Send private message

PostPosted: Fri Nov 04, 2011 6:46 am     Reply with quote

I don't understand why you have so many printf's if you have already put it
into a function.

In one of my programs I created a function for my printf that had three
parameters and reduced my printfs from over 30 down to 2 and my ROM
usage almost 50%

The same for lcd_putc.
_________________
Google and Forum Search are some of your best tools!!!!
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