Shop OBEX P1 Docs P2 Docs Learn Events
DS1302 Real Time Clock Help - P1 Spin — Parallax Forums

DS1302 Real Time Clock Help - P1 Spin

I am working towards the construction of an alarm clock, and I am first familiarizing myself with the components. I am working on telling time right now.

With the ds1302_full example code on the OBEX, there is a section of code involving the onboard trickle-charge circuit. The manual is extremely adamant about NOT activating this circuit due to the presence of the backup battery. Bottom line: is the demo program safe to run?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2019-02-18 23:40
    The datasheet for the DS1302 is quite clear that the device powers up with the trickle charging circuit disabled and there's a very specific pattern of bits that has to be sent to the device's trickle charger control register to enable it. The demo code only sends a zero byte to this control register which disables the trickle charger if it's on. "is the demo program safe to run" ... should be. I can imagine some specific sequence of cosmic rays that might occur once before your alarm clock turns to dust that could cause it to send a specific code to the DS1302 that might cause it to turn on the trickle charger, but, under normal circumstances, this wouldn't happen.

    More likely is the possibility of a bug in your program that might cause it to store data over the code that interacts with the DS1302 such that it sends the "forbidden" byte value to the DS1302's control register. Best thing to do is to not connect a backup battery until your program is working properly. There are other ways you can protect the backup battery even if the trickle charger is turned on somehow, but we're talking about extremely unlikely events.
  • tomcrawfordtomcrawford Posts: 1,126
    edited 2019-02-18 23:50
    Don't use a battery for backup, use a large (say 0.1 Farad) capacitor.

    Edit: The 1302 is really pretty obsolete. A much better choice is the DS3234. Why? Because it has an on-board crystal and you don't have to worry about choosing the right crystal with the right capacitors and the right physical layout.
  • +1
  • @"Mike Green"
    Thank you. I will get going on the demo code.

    @tomcrawford
    I purchased the module sold by Parallax. Do I really need a support circuit for it?
  • The module is "ready-to-go". For new designs, the DS3234 is easier to use. Parallax's DS1302 module works fine though. You don't need any sort of support circuit.
  • My bad, didn't realize parallax sold a module.
  • No problem, Tom.
    Thanks for the clarification, Mike.
Sign In or Register to comment.