Shop OBEX P1 Docs P2 Docs Learn Events
Ds 1302 auto detection before programming — Parallax Forums

Ds 1302 auto detection before programming

hmlittle59hmlittle59 Posts: 404
edited 2007-09-04 04:30 in General Discussion
Hello All,
First this is a copy for help I sent to Mike and Chris, from the Private form. I'm new to MC and this form is taking some getting use to.
Sorry for not being to clear, the demo program works find. I've modified it some and all is still working well. The DS1302 chip returns a value of $80 when NOT programed(this seems to be consistent), but after I read this value the ds1302 locks up...I capture the Seconds location twice with a PAUSE 3000 in between. If values are different, then I assume the clock is running(all is swell). If values are the same ($80) then GOTO setup clock routine with defaults or input routine but this is were it locks up.
All this is before being programmed.
QUESTIONS:
1) How can I verify that it's not initialized...not running?
2) Is there a Bit to check and see if it's not-running?
3) In case my board resets it can avoid loading default time.
4) I used the readburst routine from the demo(long/short format of time&date)

thanks again for your time and effort

howard m little
ps. my other messages in the public seems to be floating out there in space some where.

Comments

  • Skywalker49Skywalker49 Posts: 172
    edited 2007-09-03 12:35
    Howard,

    a bit confusing .. you write "I've modified it some and all is still working well" and later you say that the DS1302 locks up after the read. So what is working well ?

    I have no problems with the DS1302.
    Can you share the code and scheme that you use ?

    Thx, Ed
  • hmlittle59hmlittle59 Posts: 404
    edited 2007-09-03 17:22
    Hello Skywalker49 and all,

    My original problem is detecting the DS1302 chip before it is programed with the demo software. But I removed and returned power, then used the burstread routine from the demo software to read the chip. That's when I got the value $80 and the DS1302 locked up. I can reset again and all is swell. But I just want to be able to detect the ds1302 chip before it is program and know that it needs programming.

    Sorry for posting only the middle of the conversation. I have not made it to attaching code yet. But its the burst read routine from the demo.


    thx again

    hmlittle59
  • Skywalker49Skywalker49 Posts: 172
    edited 2007-09-03 17:52
    Howard,

    $80 in the seconds register (highest bit set to 1) means that the chip is in low-power standby mode.
    I can imagine that performing a burst read while the chip is such mode things could go wrong.
    What you should do is read the seconds register and test the highest bit.
    If it is zero, that means that the clock is running and date/time should be ok if previously set.
    If the value is 1, then write a 0 to that bit and set date/time.

    Good luck,
    Ed
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-09-04 04:30
    Hello,

    Ed is correct in that you should set the seconds register before the chip will start counting. Reading the seconds register will let you know if it is because of the high bit being set. Sorry it took so long to answer but I have been fighting a tough one for a cold. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.