Which is which
Could someone please explain the order of bits in the byte below.· Which is lsb and do they just go from left to right or right to left .· RTCCmd is 00010
SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Value]
\2,Value]
·LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Value]
Comments
(MSB) is on the left. 00010 is 2 decimal.
Original Message
Could someone please explain the order of bits in the byte below. Which is
lsb and do they just go from left to right or right to left . RTCCmd is
00010
SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Value]
\2,Value]
LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Value]
>Which is lsb and do they just go from left to right or right to left
>. RTCCmd is 00010
>
>SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Value]
>
>\2,Value]
>
> LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Value]
The bits in your example will be transmitted in a funny order. Each
_element_ in your list of values will be transmitted lsb first. They
will come out as follows (assuming value=15, binary 00001111).
0010000111110000
^^^^^^^^-value lsb first
^^-\2 lsb first
^^^^^-\5 lsb first
^-\1
The bits appended to value are probably some command information.
How are they supposed to come out?
-- Tracy
chip uses the time function in the 24 hour format. I am attempting to
change the command byte to use it in 12 hour time. The seventh bit is
suppose to designate 12 or 24 hour time and the fifth bit is suppose to be
AM or PM. I am having a hard time figuring out which bit to change but your
response helps. Is not (%0\1,RTCCmd\5,%10\2) the same as 00001010 if RTCCmd
= 00010 Each command is a byte long.
Sorry, the color of my fonts in the editor is white and I thought I just
pasted one command.
This is the actual line of code:
SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Value]
---- Original Message
From: "Tracy Allen" <tracy@e...>
To: <basicstamps@yahoogroups.com>
Sent: Tuesday, May 29, 2001 11:51 AM
Subject: Re: [noparse][[/noparse]basicstamps] Which is which
> >Could someone please explain the order of bits in the byte below.
> >Which is lsb and do they just go from left to right or right to left
> >. RTCCmd is 00010
> >
> >SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Value]
> >
> >\2,Value]
> >
> > LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Value]
>
> The bits in your example will be transmitted in a funny order. Each
> _element_ in your list of values will be transmitted lsb first. They
> will come out as follows (assuming value=15, binary 00001111).
>
> 0010000111110000
> ^^^^^^^^-value lsb first
> ^^-\2 lsb first
> ^^^^^-\5 lsb first
> ^-\1
>
> The bits appended to value are probably some command information.
> How are they supposed to come out?
>
> -- Tracy
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
I think your confusion arises because the commands are really 16 bits
long, not 8. The 12/24 and pm bits are in the second byte. Here is
the sequence of bits you have to send to the DS1302 to set the
"hours" register--Please read this sequence from right to left,
because you are going to send it least significant bit first:
1010011010000100
0--low for write
00010--address register 2
0--address clock (not RAM)
1--write enable
00110--6 o'clock
1--pm
0--nothing
1--specify 12 (not 24) hour format
You can deliver that to the DS1302 in several different ways.
high rst
SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%1010011010000100\16]
low rst
or
x var word
X=%1010011010000100
high rst
SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]X\16]
low rst
or
x var word
clock12 con %10000000
pm con %00100000
hoursR con 2<<1 ' shift left to put it in position
writeC con %10000000
x.byte0=writeC + hoursR
x.byte1=clock12 + pm + 6
high rst
SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]x\16]
low rst
I think you did have it almost right, but I prefer to combine all of
the command values into one word as above and then send it:
value=%10100110
SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,%00010\5,%10\2,value]
You wondered specifically about how to set the 12/24 bit and the pm
bit. Those are in the 5th and 7th bits of what you called "value".
10100110
^^^^^--6 o'clock
^--pm
^--12 hour clock
-- regards,
Thomas Tracy Allen Ph.D.
electronically monitored ecosystems
mailto:tracy@e...
http://www.emesystems.com
>Tracy, the command is for a DS1302 timechip. All the code I have for this
>chip uses the time function in the 24 hour format. I am attempting to
>change the command byte to use it in 12 hour time. The seventh bit is
>suppose to designate 12 or 24 hour time and the fifth bit is suppose to be
>AM or PM. I am having a hard time figuring out which bit to change but your
>response helps. Is not (%0\1,RTCCmd\5,%10\2) the same as 00001010 if RTCCmd
>= 00010 Each command is a byte long.
>
>Sorry, the color of my fonts in the editor is white and I thought I just
>pasted one command.
>This is the actual line of code:
>SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,value]