PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Oct 05, 2012 4:54 pm |
|
|
You want to convert a bit number to a bitmask. Use a lookup table.
With the following table placed above main(), you can now put in code
in main() to get the bitmask. Use a number from 0 to 7 as the index
to get the bitmask for bit number 0 to 7. For bit 0, you will get 0x01,
and for bit 7 you will get 0x80, etc.
Code: |
int8 const bitmask_table[] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
|
To use your incoming numbers as index values for this table, you will
need to convert them from ASCII characters to binary digits in the range
from 0 to 7.
This post may have some hints.
http://www.ccsinfo.com/forum/viewtopic.php?t=48590&start=3 |
|