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 support@ccsinfo.com

read bit from byte

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







read bit from byte
PostPosted: Sat Jan 02, 2010 7:06 pm     Reply with quote

How do I read one bit in a byte in PCM 4.037? For this specific example I am reading a byte from a register over SPI and only care about bits 7, 3, 2, and 1. The rest are don't care. I can read the byte just fine, but, I'm stuck figuring out to to only look at the bits I care about.
dyeatman



Joined: 06 Sep 2003
Posts: 1931
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Jan 02, 2010 10:13 pm     Reply with quote

To mask off bits you can use the bitwise AND (&).

See #bit in the CCS manual for how to assign variables to individual bits in a variable.

You can also use bit_test() to test the state of bits in a variable.


PCM, Thanks for catching my error in the mask info and letting me know! (now corrected) Smile
_________________
Google and Forum Search are some of your best tools!!!!
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