Page 1 of 1

Remote Control

Posted: 28 Oct 2010 13:31
by nsilva
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;
}
}
--------------------------------------------------------

Re: Remote Control

Posted: 29 Oct 2010 15:33
by filip
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.