Two bit parallel signal
kingneb
Posts: 65
How do you concatinate four two bit values onto the end of one another? I have a signal coming from the PC's parallel port two bits at a time. I need to assemble those four two bit values as a byte.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Too many lies from the right, which is the wrong side of the tracks.
Post Edited (kingneb) : 11/2/2005 10:59:56 PM GMT
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Too many lies from the right, which is the wrong side of the tracks.
Post Edited (kingneb) : 11/2/2005 10:59:56 PM GMT
Comments
--> http://forums.parallax.com/showthread.php?p=553414
You have two know when you have your two bits -- which means you actually need a third signal (latch, strobe, whatever you want to call it) unless you can guarantee that there will always be a bit change. In either case, grab the bits, shift them to their proper position, OR them with the final result.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 11/2/2005 10:54:11 PM GMT
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
Available now... SX-Video OSD module $59.95 www.sxvm.com
Those that would give up freedom for security will have neither.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Too many lies from the right, which is the wrong side of the tracks.
Post Edited (kingneb) : 11/2/2005 11:00:38 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Too many lies from the right, which is the wrong side of the tracks.
Both are in the help file -- please have a read (see Reference -> Operators)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
y var byte
result var byte
x = 3
y = 2
result = x >> y
would this assemble a nibble properly? I know this is not the full byte however I want to see If I have the right idea. I never had to use bitwise operations this etensively before.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Too many lies from the right, which is the wrong side of the tracks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
This statement moves the two bit unit over to the second highest position:
How do you move unit1 to the highest position and unit2 to the second highest position? The result should be 11100000.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Too many lies from the right, which is the wrong side of the tracks.
result = 0
result = result | (bitsIn1 << 6) <-- these are the highest bits
result = result | (bitsIn2 << 4)
result = result | (bitsIn3 << 2)
result = result | (bitsIn4) <-- these are the lowest bits
Please understand that this is pseudo-code to demonstrate the process; you'll have to clean it up to actually run it through the SX/B compiler.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Too many lies from the right, which is the wrong side of the tracks.