PDA

View Full Version : Bit set question



nverma
- 2nd April 2007, 19:13
Hi,

I want to set a particular bit of a word, so I am doing it this way:

If channel < 16 then

control1.(channel + 1) = 1

endif

I want to set the (channel + 1)th bit of control1 to 1. The complier does not like this. Do you know how else I can do this?

Thanks

Darrel Taylor
- 2nd April 2007, 19:27
control1.0(channel + 1) = 1

or

control1.1(channel) = 1
<br>

nverma
- 2nd April 2007, 19:50
Thanks....so just to confirm

This command does change the (channel + 1)th bit right and not the 0th bit of control1?

Darrel Taylor
- 2nd April 2007, 21:03
Yes. The (channel + 1) bit.

By putting the .0 after the variable name, it forces PBP to use it as a BIT Array, regardless of what the original variable was defined as.

If you use .0 then it starts at bit0
If you use .5 it starts at bit5. An index value of 0 will set bit5. An index of 4 will set bit0 in the next byte.
<br>

nverma
- 2nd April 2007, 21:23
Thanks a lot!