PDA

View Full Version : Ds1302



Dave A
01-16-2006, 02:35 AM
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

Jon Williams
01-16-2006, 02:41 AM
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 Williams
01-16-2006, 02:43 AM
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 Savage
01-16-2006, 09:05 AM
Dave,

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

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)