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

Simple and cool CCS coding tricks

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



Joined: 02 Oct 2011
Posts: 12
Location: Tunisia

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

Simple and cool CCS coding tricks
PostPosted: Thu Oct 06, 2011 6:06 pm     Reply with quote

hello

There just two simple tricks I wanted to share.
Maybe you could find them useful.

code "block" folding:

Sometimes you really wanna "fold" some code like for example
declarations, initializations and code you're "sure about" !
CCS folds code pretty well but lets try something.
Code:

#define fold if(1) // fold is now equivalent to if(1): always true.

//then we surround the code we wanna fold ..

fold{
 setup_adc_ports(NO_ANALOGS);
 setup_adc(ADC_OFF);
 setup_psp(PSP_DISABLED);
 setup_spi(SPI_SS_DISABLED);
 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
 setup_timer_1(T1_DISABLED);
 setup_timer_2(T2_DISABLED,0,1);
 setup_comparator(NC_NC_NC_NC);
 setup_vref(FALSE);
}

//we get like this





This way you can fold whatever code block you want.
I didn't find a built-in feature that would allow me to do the same !

code block un/commenting:

CCS has a feature to "toggle comments" but I like this trick better.
Here's some code we wanna toggle comments around it.
Code:


///*
printf("Dbg: Total=%u",total);
delay_ms(1000);
//*/


To toggle the comment block just remove/restore the first two slashes. (//)

I hope this is fine and useful.
Any tricks about coding, .. debugging .. please share it Smile
_________________
for(;;);
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