CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Addressing individual bits of a register

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
andyd



Joined: 08 Mar 2007
Posts: 30

View user's profile Send private message

Addressing individual bits of a register
PostPosted: Sat Apr 07, 2007 9:55 am     Reply with quote

What's the syntax to set or clear a particular bit of a register?

I've got the line CCP1CON.5 = 1; to set bit 5 of that register (CCP1CON is already defined as #byte CCP1CON = 0x17), but the compiler doesn't like it (keeps saying I need a ; on that line).
Ttelmah
Guest







PostPosted: Sat Apr 07, 2007 10:18 am     Reply with quote

#bit DC1B1=CCP1CON.5

You can then just set this to 1' or '0' when required.

DC1B1=1;
or
DC1B1=0;

Alternatively:

bit_set(CCP1CON,5);

bit_clear(CCP1CON.5);

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group