Bit masking on WAITPEQ
Sniper King
Posts: 221
In the case of WAITPEQ what would be the bit mask for 10
Is it 1010 or is it 1000000000
considering the example has
waitpeq(%0100, %1100, 0) 'Wait for P3 & P2 to be low & high
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Digital Technology Group
Is it 1010 or is it 1000000000
considering the example has
waitpeq(%0100, %1100, 0) 'Wait for P3 & P2 to be low & high
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Digital Technology Group
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
10_0000_0000 = 512 = 2^9.
A series of masks for the pins 0 through 3 would be:
0001 = 1 = 2^0
0010 = 2 = 2^1
0100 = 4 = 2^2
1000 = 8 = 2^3
What Paul is doing is using SPIN shortcuts to shift a single bit over X times, and OR'ing that with other single bits shifted X times.
That's the "<" operator above, followed by the number of shifts.
Set a bit to a 1 and you've impacted the pin associated with that particular bit, one bit per pin, for a total of 32 bits and 32 pins!
If you want pins 1 and 2, then it's this:
0110 = 2 + 4 = 6.
The addition is like an OR, in that adding single bit values (powers of two) together sets those bits in the mask.
0100
or
0010
equals
0110
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
Chat in real time with other Propellerheads on IRC #propeller @ freenode.net
Post Edited (potatohead) : 8/28/2008 10:22:25 PM GMT