??? 07/27/07 20:15 Read: times |
#142470 - A Simpler Way? |
anybody have a simple way of doing this. Basically I have a variable 'Channel' and need to turn on a bit in a register 'ADCF'
I am not really a total wiz at C yet. I am sure this is simple stuff I tried ADCF= 1 << Channel. did not really work. switch(Channel) { case 0: ADCF=1; break; case 1: ADCF=2; break; case 2: ADCF=4; break; case 3: ADCF=8; break; case 4: ADCF=16; break; case 5: ADCF=32; break; case 6: ADCF=64; break; case 7: ADCF=128; break; } |
Topic | Author | Date |
A Simpler Way? | 01/01/70 00:00 | |
Logical AND ? | 01/01/70 00:00 | |
Shift? | 01/01/70 00:00 | |
I Agree. | 01/01/70 00:00 | |
Another Option | 01/01/70 00:00 | |
the simplest way | 01/01/70 00:00 | |
capitals | 01/01/70 00:00 | |
I copyued what the OP used | 01/01/70 00:00 | |
The common use of CAPs in C | 01/01/70 00:00 | |
totally agree, however | 01/01/70 00:00 | |
Why are you rambling about variables... | 01/01/70 00:00 | |
not to me | 01/01/70 00:00 | |
Variable capitalisation? | 01/01/70 00:00 | |
'code 'never is | 01/01/70 00:00 | |
Did not think it mattered. | 01/01/70 00:00 | |
Code modifier | 01/01/70 00:00 | |
both | 01/01/70 00:00 | |
Use both | 01/01/70 00:00 | |
C++ ? | 01/01/70 00:00 | |
Mixed | 01/01/70 00:00 | |
Extensions | 01/01/70 00:00 | |
Experience | 01/01/70 00:00 |