Shiftout
Archiver
Posts: 46,084
Hello guys!
First a little background. I just found this group today and it looks
awesome. I look forward to learning from all of you!
I have had a little experience with the 68HC11 in the past, however I
have just got my BS2-SX and trying to learn the code.
In particular, one line (I'm sure is trivial to you guys!) I am
having trouble understanding.
SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Value]
It is used to write info to a RTC....
I understand most of it but eh "%0\1" and "%10\2"
I understand the \1 and \2 pertain to the amount of bits being
shifted in, but what do the other numbers reference? Is the %0 a
binary 0 for the LSB and the %10 a binary 2 in the MSB? Then what
about Value, how does the variable fit in?
Thanks for you help.
First a little background. I just found this group today and it looks
awesome. I look forward to learning from all of you!
I have had a little experience with the 68HC11 in the past, however I
have just got my BS2-SX and trying to learn the code.
In particular, one line (I'm sure is trivial to you guys!) I am
having trouble understanding.
SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Value]
It is used to write info to a RTC....
I understand most of it but eh "%0\1" and "%10\2"
I understand the \1 and \2 pertain to the amount of bits being
shifted in, but what do the other numbers reference? Is the %0 a
binary 0 for the LSB and the %10 a binary 2 in the MSB? Then what
about Value, how does the variable fit in?
Thanks for you help.
Comments
specified with %, hex are specified with $. So, you got it right. With
SHIFTOUT and SHIFTIN, if the bits parameter is not specified then eight
bits is assumed, so value will be clocked out in eight bits.
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: adamsabados2000@y... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=MEgBjkzzVbiEswF-b-pix7AgKN7TjVrRbHfMQCNe2m9Ae5RyRzrTb7ld9kftudBdGk7hWvjzRFbAVmqvAu0]adamsabados2000@y...[/url
Sent: Tuesday, December 16, 2003 7:15 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] SHIFTOUT
Hello guys!
First a little background. I just found this group today and it looks
awesome. I look forward to learning from all of you!
I have had a little experience with the 68HC11 in the past, however I
have just got my BS2-SX and trying to learn the code.
In particular, one line (I'm sure is trivial to you guys!) I am
having trouble understanding.
SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Value]
It is used to write info to a RTC....
I understand most of it but eh "%0\1" and "%10\2"
I understand the \1 and \2 pertain to the amount of bits being
shifted in, but what do the other numbers reference? Is the %0 a
binary 0 for the LSB and the %10 a binary 2 in the MSB? Then what
about Value, how does the variable fit in?
Thanks for you help.
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/basicstamps/
To unsubscribe from this group, send an email to:
basicstamps-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....
>
>First a little background. I just found this group today and it looks
>awesome. I look forward to learning from all of you!
>
>I have had a little experience with the 68HC11 in the past, however I
>have just got my BS2-SX and trying to learn the code.
>
>In particular, one line (I'm sure is trivial to you guys!) I am
>having trouble understanding.
>
>SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Value]
>
>It is used to write info to a RTC....
>
>I understand most of it but eh "%0\1" and "%10\2"
>
>I understand the \1 and \2 pertain to the amount of bits being
>shifted in, but what do the other numbers reference? Is the %0 a
>binary 0 for the LSB and the %10 a binary 2 in the MSB? Then what
>about Value, how does the variable fit in?
>
>Thanks for you help.
Suppose
RTCCmd=%11010 ' the command to the device
and
Value=%11001100 ' the value that needs to be transmitted for the
command to act on
Then reading from left to right as time progression, this is what the
SHIFTOUT will send:
0 01011 01 00110011
The spaces are for clarity in connection with the example syntax.
Each group of 1, then 5, then 2, then 8 is sent in succession, and
each one is sent least significant bit first. Those need to be put
together with some fillers, so a total of 16 bits is transmitted.
Another way to accomplish this would be to assemble it all into one
word, and then send that:
x VAR Word
x = Value<<8 + %10 << 5 + RTCCmd << 1 ' operations left to
right, makes x= %1100110010110100
SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]x\16] ' send all 16 bits.
-- Tracy
I think I've got the hang of it now!