Shop OBEX P1 Docs P2 Docs Learn Events
SX48 and the DS1302 Real Time Clock — Parallax Forums

SX48 and the DS1302 Real Time Clock

JDOhioJDOhio Posts: 72
edited 2007-04-09 16:05 in General Discussion
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

Comments

  • BeanBean Posts: 8,129
    edited 2006-06-30 02:23
    Joe,
    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
    ·
  • JDOhioJDOhio Posts: 72
    edited 2006-06-30 10:08
    Thanks! I'll try that tonight.

    Joe
  • JDOhioJDOhio Posts: 72
    edited 2006-07-01 16:08
    I have this working. In addition to porting

    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
  • SteveDSteveD Posts: 64
    edited 2006-07-04 11:36
    I converted Jon's DS1307.SXB code to work with the DS1302, SX28 and hyperterminal.· So far it seems to be working.
    If your interested.
  • JDOhioJDOhio Posts: 72
    edited 2006-07-04 13:17
    Thanks! I'll take a look.

    Joe
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2006-07-09 23:51
    Can you post a schematic showing how it is supposed to be connected?

    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.
    ·
  • SteveDSteveD Posts: 64
    edited 2006-07-10 05:13
    I did my best to draw it out I hope not but there could be some mistakes in how I have reprsented some parts.· I am fairly sure about the connections.· I used the DB9 connector and MAX232 that is on the PDB.· I have not actually wired up all of the components in the drawing I just added the DS1302 to the development board.· Hope this helps.
    Steve

    This is using the SX28.
    2160 x 1660 - 217K
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2006-07-10 11:15
    This looks great. I can build this initially from my Professional Development Board too. I am assuming the 1 uf caps in your drawing are actually 0.1 uf caps as per the PDF schematic drawings. It looks like all I will have to do is add a 22K resistor and connect the DS1302 and associated components (e.g. 1K resistor and crystal). Opps, I see that you are not using the 1K resistor from pin 6 on the DS1302 (as shown in the Stampworks 1 Experiment 30 for the BS2). Is this just a mistake or is it not needed for use with the SX28?

    Has anyone else·attempted something similar yet (e.g. connecting a DS1302 to an SX-28)?

    Thanks.
  • SteveDSteveD Posts: 64
    edited 2006-07-10 12:16
    T&E,
    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
  • JDOhioJDOhio Posts: 72
    edited 2006-07-10 22:09
    I used some of the code improvements that Steve D made to the DS1302 sample code for BS2, and have my DS1302 connected to RC.0 through RC.2 (these are just closest to the DS1302 on my protoboard). Everything is working as expected (the clock is a little fast so I may have to tweak the crystal connection).
    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
  • SteveDSteveD Posts: 64
    edited 2006-07-11 04:48
    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.
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2007-03-20 02:32
    Has any additional SX28 / 48 / 52 code been developed for use with the DS1302 (besides Jon's posted code with Hyperterminal)?
  • T&E EngineerT&E Engineer Posts: 1,396
    edited 2007-04-09 16:05
    Here is a completed DS1302 SX28/48/52 LCD project and another one using an SX48/52 controlling a 16x16 LED matrix and a DS1302:

    http://forums.parallax.com/showthread.php?p=643780



    http://forums.parallax.com/showthread.php?p=643775
Sign In or Register to comment.