SX48 and the DS1302 Real Time Clock
I am driving the DS1302 Real Time Clock Chip from the SX48. I am attempting to port the BS2 example to SX/B. The following SHIFTOUT command throws a compile error (invalid number of parameters). It looks like the last argument is building a byte and placing it into the variable named Value. I'm guessing the compiled can't interpret this. Any ideas how to port this?
Clk VAR RC.0
Dta VAR RC.1
RTCCS VAR RC.2
RTCCmd VAR BYTE
Value VAR BYTE
SHIFTOUT Dta, Clk, LSBFIRST,[noparse][[/noparse]%0\1,RTCCmd\5,%11\2,Value]
Thanks,
Joe
Clk VAR RC.0
Dta VAR RC.1
RTCCS VAR RC.2
RTCCmd VAR BYTE
Value VAR BYTE
SHIFTOUT Dta, Clk, LSBFIRST,[noparse][[/noparse]%0\1,RTCCmd\5,%11\2,Value]
Thanks,
Joe
Comments
You need to break it into seperate SHIFTOUT commands
Something like:
SHIFTOUT Dta, Clk, LSBFIRST,%0\1
SHIFTOUT Dta, Clk, LSBFIRST,RTCCmd\5
SHIFTOUT Dta, Clk, LSBFIRST,%11\2
SHIFTOUT Dta, Clk, LSBFIRST,Value
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"I reject my reality, and substitute yours." NOT Mythbusters
·
Joe
SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Value]
to
SHIFTOUT Dta, Clk, LSBFIRST,%0\1
SHIFTOUT Dta, Clk, LSBFIRST,RTCCmd\5
SHIFTOUT Dta, Clk, LSBFIRST,%11\2
SHIFTOUT Dta, Clk, LSBFIRST,Value
I had to adjust the LOOKUP syntax in the sample code from
LOOKUP Idx,[noparse][[/noparse]0,Seconds,Minutes,Hours,Date,Month,Day,Year,128],Value
to
LOOKUP Idx,0,Seconds,Minutes,Hours,Date,Month,Day,Year,128,Value
Note that the brackets ([noparse][[/noparse] and ]) are removed. When the compiler found the brackets, it ignored the first and last values of the set of values (0 and 128 in this case). When that happens, the Real Time Clock Chip would not receive the Control Register values. When that happens, the Real Time Clock Chip spits out invalid values for the date and time. By removing the brackets, the code compiles correctly and the Real Time Clock Chip returns valid values for data and time.
Thanks for the help!
Joe
If your interested.
Joe
Will it work for an SX-28?
I am interested in using a DS1302 with an SX-28 on a breadboard and can't find any info on how to do this (other than for the BS2).
Thanks.
·
Steve
This is using the SX28.
Has anyone else·attempted something similar yet (e.g. connecting a DS1302 to an SX-28)?
Thanks.
Concerning the 1k resistor you are correct I over looked that, it should be there on pin 6. As for the caps I am not sure. The PDB diagram shows .1uf like you said, the data sheet from Maxim appears to me to say 1uf at the begining of the sheet. I think I read on the data sheet you could use as much as 10uf.
Steve
I am not using resistors to interface to the SX48 and didn't locate information on Maxim's site recommending resistors. Any idea on the purpose of the resistors for the SX28?
Joe
I do not have the knowledge to explain the resistor, but it is my understanding it is used for protectection in case one components pin is low at the same time the other components pin (on the same wire) is high. I am sure this is a poor and incorrect description but I am sure the resistor is there for insurance against damage to either component should they try to communicate with each other at the same time.
http://forums.parallax.com/showthread.php?p=643780
http://forums.parallax.com/showthread.php?p=643775