View previous topic :: View next topic |
Author |
Message |
40inD
Joined: 30 Jul 2007 Posts: 112 Location: Moscow, Russia
|
how to work with byte as bit array? |
Posted: Mon Oct 06, 2014 8:06 am |
|
|
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: 19497
|
|
Posted: Mon Oct 06, 2014 9:09 am |
|
|
union |
|
|
40inD
Joined: 30 Jul 2007 Posts: 112 Location: Moscow, Russia
|
|
Posted: Tue Oct 07, 2014 1:37 am |
|
|
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
|
|
Posted: Tue Oct 07, 2014 8:51 am |
|
|
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.. |
|
|
|