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

how to work with byte as bit array?

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



Joined: 30 Jul 2007
Posts: 112
Location: Moscow, Russia

View user's profile Send private message

how to work with byte as bit array?
PostPosted: Mon Oct 06, 2014 8:06 am     Reply with quote

I need to sent to function a byte as argument, but inside the function i need to work with this byte like this:
byte.bit or byte[bit]
is it possible?
i.e.
Code:
output_bit(PIN_A2, byte[2]); // 3th bit of byte
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Mon Oct 06, 2014 9:09 am     Reply with quote

union
40inD



Joined: 30 Jul 2007
Posts: 112
Location: Moscow, Russia

View user's profile Send private message

PostPosted: Tue Oct 07, 2014 1:37 am     Reply with quote

solved thru bit_test
Code:
void setcode (byte cod)
{
output_bit(PIN_A2, bit_test(cod,2));
output_bit(PIN_A4, bit_test(cod,4));
output_bit(PIN_A5, bit_test(cod,5));

}
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Oct 07, 2014 8:51 am     Reply with quote

you might reconsider the very good advice from MR. "T" in the previous post, especially after you look in the .LST file to see what your code generates..
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