Page 1 of 1

pre-processor directives

Posted: Thu Jun 14, 2012 4:12 pm
by davet
Hi

I want to be able to set/ clear bits in say timer0, in C, within Flowcode 5. How do I do this in boost C? I have in the past been using the CCS compiler and in that you would use a pre-processor directive:

#byte timer_0 = 0x01

Thanks

Dave

Re: pre-processor directives

Posted: Thu Jun 14, 2012 4:51 pm
by Benj
Hello,

I think the timer register is normally named tmr0.

so using a C code icon you could do something like this.

tmr0 = 0;

or you can say load the register into a Flowcode created byte variable named reg.

FCV_REG = tmr0;

Re: pre-processor directives

Posted: Fri Jun 15, 2012 12:06 pm
by davet
Thanks Benj,

Is there a list somewhere of the pic's special function registers and their names which are of the right syntax for the C compiler to identify, the obvious ones are trisa and timer0 but what about the spbrg are they used as from the pic data sheets if so are they all lowercase.
Thanks

Dave

Re: pre-processor directives

Posted: Fri Jun 15, 2012 4:55 pm
by Benj
Hi Dave,

Yep the place to look is normally the datasheet, BoostC and HiTech etc seem pretty good at matching the names as shown there.

If you want a bulletproof reference to all the register and bit names then for BoostC you can look here using a text editor.

Flowcode Install Path\Tools\boostc\include

Then say you are using a 16F88 you would look at the PIC16F88.h file.

The list of registers is at the bottom of the file.

volatile char indf @INDF;
volatile char tmr0 @TMR0;
volatile char pcl @PCL;
volatile char status @STATUS;
volatile char fsr @FSR;
volatile char porta @PORTA;
volatile char portb @PORTB;

And the bits look like this.

/////// OSCCON Bits ///////////////////////////////////////////////////////
#define IRCF2 0x0006
#define IRCF1 0x0005
#define IRCF0 0x0004
#define OSTS 0x0003
#define IOFS 0x0002
#define SCS1 0x0001
#define SCS0 0x0000

Re: pre-processor directives

Posted: Fri Jun 15, 2012 6:50 pm
by davet
Brilliant-cheers!