Is the pipe a delimiter or bitwise OR
A few days ago I asked a question about the following snippet of code:
"For the Propeller folks out there: "ctra := %01001 << 26 | fb_pin << 9 | rf_pin" - is the pipe symbol a delimiter or bitwise OR operator?"
My initial inclination was to say, bitwise OR until I saw that the CTRA mode it was calling was %01001. And according to the table in the Parallax manual, this wasn't a logic based counter mode, it was a POS detector with feedback mode:
But, I had to clarify and make sure. So I asked and RaivisR said bitwise OR, as did Whisker as did RoyEltham.
So why is it bitwise OR?
01001 goes in the uppermost 5 bits
fb_pin and rf_pin are just setting PIN A & B
So the 3 values are OR'd together but they occupy different bit ranges so they are not going to change each other, they'll just fill in the result with the combination.
Example:
If you do this: %10100000 | %00001010
Then you will get %10101010
which is the same as this: %1010 << 4 | %1010
because %1010 << 4 = %10100000
and %1010 is the same as %00001010
This method is used to set the mode and pins for the counters in a quicker fashion.
Thought that was a cool enough reason to show it on the blog!
@atdiy/@tymkrs










