Searching \ for '[pic]: c18 structures unions and referencing bits' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: massmind.org/techref/microchip/devices.htm?key=pic
Search entire site for: 'c18 structures unions and referencing bits'.

Exact match. Not showing close matches.
PICList Thread
'[pic]: c18 structures unions and referencing bits '
2009\07\21@111347 by Justin Richards

face picon face
was tagged [tech]

2009/7/21 Justin Richards <spam_OUTjustin.richardsTakeThisOuTspamgmail.com>

{Quote hidden}

2009\07\21@205249 by Isaac Marino Bavaresco

flavicon
face
You could write a function or macro to do this.
Use a char array as the underlying type and abstract the bit access in
the function/macro:

Ex.:
void SetBit( char *v, int n )
   {
   v[n>>3] |= 1 << ( n & 7 );
   }

void ClrBit( char *v, int n )
   {
   v[n>>3] &= ~( 1 << ( n & 7 ));
   }

int ReadBit( char *v, int n )
   {
   return ( v[n>>3] & ( 1 << ( n & 7 ))) ? 1 : 0;
   }

Justin Richards escreveu:
{Quote hidden}

__________________________________________________
Faça ligações para outros computadores com o novo Yahoo! Messenger
http://br.beta.messenger.yahoo.com/

2009\07\21@235849 by Justin Richards

face picon face
Thanks Isaac,

your readbit function does the trick.

Cheers Justin


2009/7/22 Isaac Marino Bavaresco <isaacbavarescospamKILLspamyahoo.com.br>

{Quote hidden}

>

2009\07\22@090156 by Isaac Marino Bavaresco

flavicon
face
Justin Richards escreveu:
> Thanks Isaac,
>  

You are welcome.

> your readbit function does the trick.
>  

Here is a much more efficient version for up to 256 bits:

char ReadBit( char *v, char n )
   {
   return ( v[n>>3] >> ( n & 7 )) & 0x01;
   }

> Cheers Justin
>  

Best regards,

Isaac

__________________________________________________
Faça ligações para outros computadores com o novo Yahoo! Messenger
http://br.beta.messenger.yahoo.com/

More... (looser matching)
- Last day of these posts
- In 2009 , 2010 only
- Today
- New search...