Setting the BITS of a BYTE variable
fiatlux
Posts: 1
I'm fairly new to spin programming, but not to microcontrollers.
I am trying to individually set the bits in a byte variable and I can only seem to set the LSB.
I have the Propellor hooked up to an addressable 16 input mux chip (74150), and I want to compile the information into 2 BYTE variables so I can send them out serially.
Here is the code that I am using:
Can anyone give me any insight into what I am doing wrong?
Thanks.
Thanks,
I am trying to individually set the bits in a byte variable and I can only seem to set the LSB.
I have the Propellor hooked up to an addressable 16 input mux chip (74150), and I want to compile the information into 2 BYTE variables so I can send them out serially.
Here is the code that I am using:
repeat repeat address from 0 to 7 outa[d_pin..a_pin] := address waitcnt(10000 + cnt) if ina[w0_pin]==1 status[address] := 1 else status[address] := 0status and address are both BYTE variables.
Can anyone give me any insight into what I am doing wrong?
Thanks.
Thanks,
Comments
varb |= |< 5 ' set bit 5 high
to set a bit low, do this:
varb &= !|< 3 ' set bit 3 low
This is breaking it down into simplest terms. I hope this helps.
Edit, I see Bob replied, you can use his method as well. If you have additional questions about how he is doing that please ask.