pre-processor directives

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
davet
Posts: 27
Joined: Mon Jun 11, 2012 11:08 am
Been thanked: 1 time

pre-processor directives

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: pre-processor directives

Post 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;

davet
Posts: 27
Joined: Mon Jun 11, 2012 11:08 am
Been thanked: 1 time

Re: pre-processor directives

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: pre-processor directives

Post 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

davet
Posts: 27
Joined: Mon Jun 11, 2012 11:08 am
Been thanked: 1 time

Re: pre-processor directives

Post by davet »

Brilliant-cheers!

Post Reply