Page 1 of 1

accessing individual bits in sfr's

Posted: Fri Jun 15, 2012 3:39 pm
by davet
Hi

I want to access the individual bits in the rcsta register by their names ie cren, and not by rcsta.4.
so I can say set bit/ clear bit "cren" by name.
Hope someone can help me with this as I have rephrased an earlier post to get a response.
Thanks

Dave

Re: accessing individual bits in sfr's

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

This should work,

set_bit(rcsta, CREN);

or

clear_bit(rcsta, CREN);

or

rcsta.CREN = 1;

or

rcsta.CREN = 0;

The rule in BoostC is lowercase register name and uppercase bit name.

Re: accessing individual bits in sfr's

Posted: Fri Jun 15, 2012 6:47 pm
by davet
Thanks for that!
BW