ünloco
Joined: 02 Oct 2011 Posts: 12 Location: Tunisia
|
Simple and cool CCS coding tricks |
Posted: Thu Oct 06, 2011 6:06 pm |
|
|
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 _________________ for(;;); |
|