Shop OBEX P1 Docs P2 Docs Learn Events
Ds1302 — Parallax Forums

Ds1302

Dave ADave A Posts: 31
edited 2006-01-16 02:05 in BASIC Stamp
I am trying to use the DS1302 to add the total time an object is being turned on over a time period.· I am not having any luck in stoping the clock.· I can set times, read times· and reference times.· But I am not sure how to write the code to stop, but not loose the existing time, so I can continue to add to the time. Somebody's help will be appreciated.

Thanks Dave

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-15 19:41
    According to the docs (page 6, Clock Halt Flag), you can stop the clock by setting bit 7 of the seconds register. So what you'd have to do is read the seconds, OR with %10000000, then write the seconds register back. When you want to restart the clock you'd read the seconds register, AND with %01111111, and then write it back.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-15 19:43
    Note: I just had a quick look at your program and found that you're using "LOOP" as a label -- you should avoid this so you can enable PBASIC 2.5 features: things like IF-THEN-ELSE, DO-LOOP, etc.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-01-16 02:05
    Dave,

    ·· Tech Support already replied to your e-mail on this question.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.