How to accomplish this mask in spin?
T Chap
Posts: 4,223
I have 16 Propellers, each assigned an ID from %0000 - %1111. If I want to address any single device, that is easy, just send that ID. But what if I want to address device 1 and 2 only?
I thought that ORing 1 and 2 would work, and it does but is also allows #3 to be addressed: %0001 OR %0010 = %0011. In this case, if $03 is sent as a bitmask, then #1, 2, and 3 devices are able to be addressed. Likewise, If I just wanted to address #3 and #1, the same problem exists.
How do you address any or all of 16 ID's without the other values getting included that are unwanted? Or, is 4 bits not possible to do this inside, and I must use a 16 bits?
I thought that ORing 1 and 2 would work, and it does but is also allows #3 to be addressed: %0001 OR %0010 = %0011. In this case, if $03 is sent as a bitmask, then #1, 2, and 3 devices are able to be addressed. Likewise, If I just wanted to address #3 and #1, the same problem exists.
How do you address any or all of 16 ID's without the other values getting included that are unwanted? Or, is 4 bits not possible to do this inside, and I must use a 16 bits?
Comments
If your limited to 4-bits and have 16 addresses assigned to those 4-bits, then you can only address one Propeller at a time.
-Phil
What you are really trying to do it write to multiple targets at the same time.
(Will you then want to READ from multiple devices at the same time?)
I think what you want is called a Cross-Point switch...
http://en.wikipedia.org/wiki/Crossbar_switch
But the addressing confusion? What's that about?
4 bits can be four selects,
or it can be a binary encoded number (0 to F as we say in hex).
The difference is how they are used.
4 bits are used to select 4 devices
That's not addressing. That's mode /Chip Selects or /Chip Enable.
4 bits are DECODED to produce 16 selects for 16 devices.
That's the A, B, C, and D inputs:
(from digital prehistory - the 74LS154 4 to 16 decoder)
But that doesn't let you access two units at the same time.
In fact, its built to prohibit just exactly that.
One To, One From.
GPIB (General Purpose Instrument Bus) allowed multiple listeners.
iirc?
Anyway, after all that, would a straight question be in order?
What is it that you think you are doing?
Nope. 'fraid not.
If you have N possibilities then you need ceiling(log2(N)) bits to select one possibility (ceiling rounds up to next integer), its fundamental information theory.
Say you want to address one or two (but not more) devices from a set of 16. That is 16+120 = 136 possibilities which requires 8 bits. You'd have to invent a coding scheme too. Selecting just one is 16 possibilities, therefore 4 bits (obvious coding scheme). Selecting any sub-set at all from the 16 (including none) is 2^16 possibilities which is exactly 16 bits (with an obvious coding scheme).