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

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







out of code space
PostPosted: Thu Mar 20, 2003 7:55 am     Reply with quote

I'm using a 16F877 and have managed to fill up the code space.
I'm using integer math and was wondering if it would consume less space if I type-cast every math operation to my worst case (Signed Int32).

Reading the List file it appears the compiler includes different routines for the different math calls.

Would I save space by forcing every math equation to Signed Int32?
Would the compiler then not include the other math routines?

Speed is not a factor in my program, so even if the 32-bit routines took a bit longer, it wouldn't be a problem.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12871
Hans Wedemeyer
Guest







Re: out of code space
PostPosted: Thu Mar 20, 2003 11:38 am     Reply with quote

You could simply drop a PIC18F452 in place of the 877 and get lots more ROM and RAM...
___________________________
This message was ported from CCS's old forum
Original Post ID: 12883
patrick muldoon
Guest







Re: out of code space
PostPosted: Thu Mar 20, 2003 12:16 pm     Reply with quote

:=You could simply drop a PIC18F452 in place of the 877 and get lots more ROM and RAM...

But then I'd have to get the bigger compiler, which I hear may be a bit buggy. (I've had great success with the PCM.) And I'd have to change the board layout.

The code is basicly done, and all works well. I was just reading the lst file and trying to get a better understanding of how to be space-efficient just in case I need to make changes.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12885
Dale Botkin
Guest







Re: out of code space
PostPosted: Thu Mar 20, 2003 12:24 pm     Reply with quote

:=Reading the List file it appears the compiler includes different routines for the different math calls.
:=
:=Would I save space by forcing every math equation to Signed Int32?
:=Would the compiler then not include the other math routines?

It's possible. I found that using a long instead of an int value in one spot saved me some code; I already had a 16-bit divide I can't get rid of, and using an int added an 8-bit divide function. While dropping in an 18F PIC is certainly an attractive thing to be able to do, if you don't have PCWH or are using an 8-pin package and can't go any larger it may not be an option. Sure wish there was an 18-series PIC with only 8 pins and sleep current under 10 nanoamps!

Go through your code by looking at the .LST file and the stats for memory hogs. For example: are you doing signed int32 math on values whose low order bits are immaterial? Can you make them longs instead and shift the results? I found several places I could use just the high order bits of a variable, save a lot of code space, and end up with less than 1\% error. Also, I found a lot of repetitive lines of code that could be made into a function.

Operations could be rearranged to save space too; this:

b = a*c;

takes up less room that this:

b = a;
b *= c;

I have a program that curerntly uses about 1023 words in a 12F629. Almost every time I need a few more words and start really digging for them I find more ways to shrink the code. V1.0 was 1022 words; if I had applied all the shrinks to it that I have found while trying to find space to squeeze in bug fixes & features, it would probably have been under 900.

Hope this helps,

Dale
___________________________
This message was ported from CCS's old forum
Original Post ID: 12886
PCM programmer



Joined: 06 Sep 2003
Posts: 20335

View user's profile Send private message

Re: out of code space
PostPosted: Thu Mar 20, 2003 12:36 pm     Reply with quote

:=:=You could simply drop a PIC18F452 in place of the 877 and get lots more ROM and RAM...
:=
:=But then I'd have to get the bigger compiler, which I hear may be a bit buggy. (I've had great success with the PCM.) And I'd have to change the board layout.
:=
:=The code is basicly done, and all works well. I was just reading the lst file and trying to get a better understanding of how to be space-efficient just in case I need to make changes.
--------------------------------------------------------------

Here is one of my old posts, with a few tips on
how to reduce ROM size.
<a href="http://www.pic-c.com/forum/old/messages/1777.html" TARGET="_blank">http://www.pic-c.com/forum/old/messages/1777.html</a>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12887
patrick muldoon
Guest







Re: out of code space
PostPosted: Thu Mar 20, 2003 1:59 pm     Reply with quote

:=You could simply drop a PIC18F452 in place of the 877 and get lots more ROM and RAM...

Oh, I get it. The 18F452 is the same pinout...cool! I hadn't realized that. And my sourcecode should compile without any surprises, right?

Thanks for the tips, guys. That's just the kind of info I was looking for.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12890
R.J.Hamlett
Guest







Re: out of code space
PostPosted: Thu Mar 20, 2003 3:56 pm     Reply with quote

:=:=You could simply drop a PIC18F452 in place of the 877 and get lots more ROM and RAM...
:=
:=But then I'd have to get the bigger compiler, which I hear may be a bit buggy. (I've had great success with the PCM.) And I'd have to change the board layout.
:=
The board doesn't have to change. The compiler is OK now. Some of the earlier problems, where hardware faults (there is a bufg with the current 18Fxx2 silicon), and the current version has a patch round this, as well as fixing most of the other problems (there are still a few 'issues', but most are pretty simple to work round, and 90+ percent of code will run OK.

:=The code is basicly done, and all works well. I was just reading the lst file and trying to get a better understanding of how to be space-efficient just in case I need to make changes.

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 12898
Ron
Guest







Re: out of code space
PostPosted: Fri Mar 21, 2003 7:58 am     Reply with quote

I agree with R.J. Hamlett that the compiler for 18f parts is quit good now.

I had the same experience: lack of ROM forced me to move from 16f877 to 18f452.

I first tried with version 3.130 or so, but that was really not a good idea, since the 18f parts were just introduced at that time. But now, from version 3.140 and on, 18f support has really upgraded and is now working good with CCS compiler.

Good luck,
Ron


:=:=You could simply drop a PIC18F452 in place of the 877 and get lots more ROM and RAM...
:=
:=But then I'd have to get the bigger compiler, which I hear may be a bit buggy. (I've had great success with the PCM.) And I'd have to change the board layout.
:=
:=The code is basicly done, and all works well. I was just reading the lst file and trying to get a better understanding of how to be space-efficient just in case I need to make changes.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12917
Hans Wedemeyer
Guest







Re: out of code space
PostPosted: Fri Mar 21, 2003 10:11 am     Reply with quote

The PCB should NOT need any changes.

PCH is OK now... I know, I lived through it from beta to current version... it's about as good as anything out there.

Another bonus by upgrading to PIC18 is speed. The PIC18 can run at 40MHz, so if you need the speed, simply drop in a 10MHz crystal and select the PLL clock.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12922
Jim Mcbride
Guest







Re: out of code space
PostPosted: Mon Mar 24, 2003 9:55 am     Reply with quote

I used 16 bit pointers for ram usage, I want from 87\% to 32\% ram used. See help questions on RAM.
Jim

:=:=:=You could simply drop a PIC18F452 in place of the 877 and get lots more ROM and RAM...
:=:=
:=:=But then I'd have to get the bigger compiler, which I hear may be a bit buggy. (I've had great success with the PCM.) And I'd have to change the board layout.
:=:=
:=:=The code is basicly done, and all works well. I was just reading the lst file and trying to get a better understanding of how to be space-efficient just in case I need to make changes.
:=--------------------------------------------------------------
:=
:=Here is one of my old posts, with a few tips on
:=how to reduce ROM size.
:= <a href="http://www.pic-c.com/forum/old/messages/1777.html" TARGET="_blank"> <a href="http://www.pic-c.com/forum/old/messages/1777.html" TARGET="_blank">http://www.pic-c.com/forum/old/messages/1777.html</a></a>
___________________________
This message was ported from CCS's old forum
Original Post ID: 13005
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