Page 1 of 1
Set 2 bits values
Posted: Wed Nov 11, 2015 1:48 pm
by Jan Lichtenbelt
I want to set the 2bit parameter CDAFVR<1:0> of the register FVRCON. Is it possible sometime like:
fvrcon.CDAFVR=....
With kind regards
Jan Lichtenbelt
Re: Set 2 bits values
Posted: Wed Nov 11, 2015 4:44 pm
by Benj
Hi Jan,
In XC8 you can do things like this.
FVRCONbits.CDAFVR = 3;
However in BoostC things are a little different.
I think the register bits are only defined as their bit position so you can do things like this.
set_bit(fvrcon, CDAVR0);
clear_bit(fvrcon, CDAVR1);
Not really what you were after but not too bad.
Re: Set 2 bits values
Posted: Wed Nov 11, 2015 7:21 pm
by Jan Lichtenbelt
I get a C-code error "Left operand must be l-value". What can be wrong?
Kind regards
Jan Lichtenbelt
Re: Set 2 bits values
Posted: Wed Nov 11, 2015 9:54 pm
by medelec35
Hi Jan
You have got:
Code: Select all
TRISA=TRISA|0x04; // Set A2 as input
ANSELA= ANSELA | 0x04; // Set A2 as analog input
For boost C it should be:
Code: Select all
trisa=trisa|0x04; // Set A2 as input
ansela= ansela | 0x04; // Set A2 as analog input
Registers are in lower case and bit names are in upper case.
Martin