shiftout with \ operator
I believe there is a problem with the compiler when it compiles this command
shiftout dta,clk,1,x \1·· 'should send the MSB but it sends LSB???
the result is the same like
shiftout dta,clk,0,x \1
How can I fix it?
Note:
the shiftout works fine without the \ operator
Post Edited By Moderator (Bean (Hitt Consulting)) : 7/13/2007 6:13:34 PM GMT
shiftout dta,clk,1,x \1·· 'should send the MSB but it sends LSB???
the result is the same like
shiftout dta,clk,0,x \1
How can I fix it?
Note:
the shiftout works fine without the \ operator
Post Edited By Moderator (Bean (Hitt Consulting)) : 7/13/2007 6:13:34 PM GMT
Comments
The \1 assumes you are working with a 1 bit value. Therefore the MSB of a one bit value is bit 0. Of course the LSB of a one bit value is also bit 0.
If you want the MSB only, you must shift the value before using SHIFTOUT.
x = x >> 7 ' Put bit 7 into bit 0 position
SHIFTOUT dta, clk, MSBFIRST, x \1
Just to be clear if you used "MSBFIRST, x, \4" you would get bit3, bit2, bit1, bit0.
If you used "LSBFIRST, x, \4" you would get bit0, bit1, bit2, bit3.
So MSBFIRST and LSBFIRST do not affect WHICH bits you get, just what order they are in.
I have been told this is how the Basic stamps handle it too.
[noparse][[/noparse]EDIT] Just looked at the help file. At the very bottom of SHIFTOUT there is an example that explains this behavour.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Teacher: What is the difference between ignorance and apathy ?
Student: I don't know and I don't care
Teacher: Correct !
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
Post Edited (Bean (Hitt Consulting)) : 7/13/2007 6:14:22 PM GMT