accessing individual bits in sfr's

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

accessing individual bits in sfr's

Post 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

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: accessing individual bits in sfr's

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

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

Re: accessing individual bits in sfr's

Post by davet »

Thanks for that!
BW

Post Reply