Shop OBEX P1 Docs P2 Docs Learn Events
Aha moment, then AARRGH. DS1307 — Parallax Forums

Aha moment, then AARRGH. DS1307

SofalogicSofalogic Posts: 49
edited 2004-11-12 14:49 in BASIC Stamp
Gentleman:
···· I had an "Aha moment" with my DS1307. I was able to count minutes and seconds. I left power to my BS2p40 while I made small steps in the edits. However, when I removed power it no longer worked. It displayed a continuous 8080 in sequence (this was where the mins and secs were previously displayed.) I inserted a new chip to make sure I had not toasted one and it again worked. After power was removed, 8080 was displayed again.

This one is ponderous.idea.gif

Comments

  • Tracy AllenTracy Allen Posts: 6,658
    edited 2004-11-11 16:01
    If bit 7 in the seconds register is high, the clock oscillator is turned off. You have to set that bit low to make the clock run. Seconds comes up as $80 at power up. Insert code in your program that reads the seconds, if that bit 7 is high, reset the clock to some default value.

    If you want the clock to continue running when power is removed, use a 3 volt coin cell, + on pin 3.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • SofalogicSofalogic Posts: 49
    edited 2004-11-11 17:10
    Tracy:

    ···· Thanks for the quick reply. It makes sense. I checked the datasheet from DS and sure enough the "control" bit as they call it. I had been working my way down the line and put that into the code. I am going to take another shot at it and see if I can "AHA" again.

    Andrew
  • SofalogicSofalogic Posts: 49
    edited 2004-11-11 20:09
    Gentleman:

    ···· I tried what I could, to no avail. I cannot get the clock to count. I even went back to the original code. This is puzzling. Once I get the code to work I will add the 3v backup to keep it running.

    ···· Is there any other possibility?
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2004-11-11 20:34
    The 3v coin cell on pin 3 not only backs up the clock, it also acts as a threshold for operation of the serial interface. If you do not have the +3v on pin 3, the operation can seem very erratic as the pin voltage floats. If you do not use the battery, you can attach pin 3 to ground (pin 4), and at least you will be able to read the clock and it will run so long as power is attached. But hurry up and get that 3 volt battery--that is how it is supposed to work!

    Be sure you have the pullup resistors on the i2c dta and scl lines.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • SofalogicSofalogic Posts: 49
    edited 2004-11-12 01:20
    Tracy:

    ···· Seems like you are the only one willing to tackle this ponderous situation. Thanks for your help. I am using 4.7k's to pull up 5 and 6. I am actually going by the circuit in this months N&V . I am breadboarding this circuit and tacked the crystal to 1 and 2. I am getting the same response using shiftin and shiftout routines. I am sooo stuck. I think its time to move on. I might try the 1302 next.

    Oh yes. I put the button battery on to pin three and ground. Still no response.

    Andrew
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2004-11-12 03:29
    Are you using the i2c commands on a BS2p or 'pe, or are you using the code Jon suggested for making do i2c on one of the earlier Stamps? From your first message in this thread, it sounds like you had it working at first.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • SofalogicSofalogic Posts: 49
    edited 2004-11-12 04:04
    Gentlemen:
    ···· I just realized I was typing gentlman, oops. Anyhow, yes it was working earlier. It is working again. I was robbed of my·"aha" moment because it started working mysteriously. I went back to an earlier version of the code I was experimenting with, after a couple of tries it started running.·This time it started right in the middle of the run. The debug was displaying "80...80...( i had a one second pause) then boom, 01....02....03 and so on. Its been counting for 2:13 as of this message. I am puzzled.

    ·I have had luck with the i2c version of the code. I would like to get the shiftin/out version working for the bs2oem I bought. I have a few weeks to develop this before I pass it on to some students.

    Here is a copy of the code I am building on:

    '{$STAMP BS2p}
    sda CON 8
    scl CON 9
    seconds VAR Byte
    mins VAR Byte
    hrs VAR Byte

    · startcount:
    I2COUT sda, $00,0,[noparse][[/noparse]1]
    I2CIN sda,$d0,0,[noparse][[/noparse]seconds]
    DEBUG HEX2 seconds, CR
    PAUSE 1000
    · GOSUB startcount

    Thanks again for your help

    Andrew
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-12 14:49
    I've attached a DS1307 demo that will run on a BS2, BS2e, or BS2sx.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
Sign In or Register to comment.