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

Optimising tricks of the trade !

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







Optimising tricks of the trade !
PostPosted: Sun Feb 02, 2003 5:53 am     Reply with quote

Hello,

Im fairly new to PIC C, but have just completed my first project involving many of the more advanced features of a PIC (such as timer and UART interrupts).

My budget was to used a PIC16F870 and several times during the project I was faced with the dreaded OUT OF ROM message.
When this happened, I would go back through my code and check to see if I could cut down or optimise to trim down the code size, and sure enough I did.

I learnt several tricks along the way to save space and Im sure it would be of benefit to share mine, and you share yours. Here are a couple that made a big difference for me...

(Note that these may not apply to you, depending on your setup but I should imagine they will come in handy at some point!):

Instead of using:
output_low(whatever)
Use:
bit_clear(*x,y)
(also use bit_set instead of output_high)

Instead of using:
delay_ms(xxx)
Use:
for(i=0;i (I.e., use a for/loop. However a for loop instead of delay_us on the other hand does not save space)

Please post your handy tips !

Cheers,
Darren
___________________________
This message was ported from CCS's old forum
Original Post ID: 11198
mark r. hahn
Guest







Re: Optimising tricks of the trade !
PostPosted: Sun Feb 02, 2003 5:47 pm     Reply with quote

:=Hello,
--- snip ---
:=Please post your handy tips !
:=
:=Cheers,
:=Darren

I wrote a review of the CCS PCM compiler a few years back. I included several tips on how to make your programs smaller. Most of what I wrote then still holds. You might wish to check out my web page: <a href="http://home.hvc.rr.com/mhahn/HahnTronix.html" TARGET="_blank">http://home.hvc.rr.com/mhahn/HahnTronix.html</a>

Happy crunching,

Mark Hahn
___________________________
This message was ported from CCS's old forum
Original Post ID: 11214
Darren Logan
Guest







Re: Optimising tricks of the trade !
PostPosted: Wed Feb 26, 2003 6:41 pm     Reply with quote

Hello,

My program contained several write_eeprom and read_eeprom commands.

I replaced them with my own read/writes thus:

void writetoeeprom(int addr, int data) {

write_eeprom(addr,data);

}

int readfromeeprom(int addr) {

return(read_eeprom(addr));

}

This made a significant difference.

Regards,
Darren
___________________________
This message was ported from CCS's old forum
Original Post ID: 12149
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