Remote Control

General discussion on mikroC.
Post Reply
Author
Message
nsilva
Posts: 58
Joined: 09 Nov 2004 14:55
Location: Brasil

Remote Control

#1 Post by nsilva » 28 Oct 2010 13:31

How can I set the bit 31 of a variable type unsigned long.

--------------------------------------------------------
unsigned long code;
unsigned char i;

void main(){
for(i=0;i<=31;i++){
if (PORTB.F0==1)
code.F31=1;
else
code.F31=0;

code=code >> 1;
}
}
--------------------------------------------------------

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Remote Control

#2 Post by filip » 29 Oct 2010 15:33

Hi,

To access an individual bit of a variable you can use a masking algorithm (using a bit pattern to select some bits).

For more information on this subject, see this page :
http://en.wikipedia.org/wiki/Mask_%28computing%29

Without masking, at the moment, you can access only char type.

Regards,
Filip.

Post Reply

Return to “mikroC General”