Shop OBEX P1 Docs P2 Docs Learn Events
Heads up.. found a minor glitch..bs2 and ds1302 rtc — Parallax Forums

Heads up.. found a minor glitch..bs2 and ds1302 rtc

NR1XNR1X Posts: 111
edited 2008-09-18 09:58 in BASIC Stamp
last night while tring to configure and set time to ds1302 rtc, i stumbled across this... when i ran the code it would not change time and date... found that if i disconnected power from homework board for a few secs then reconnect power while editor said scanning, it worked every time.. attached is my code,. maybe a seasond stamp veteran can find a glitch in my code.... has anyone else had this issue?? what a mess took me hours to figure this out, hope this saves someone some headaches...
NOTE gosub write rtc is commented to prevent accidental write in a powerloss, this was changed after my issues

Post Edited (kb1nrb) : 9/17/2008 10:12:32 AM GMT

Comments

  • Tracy AllenTracy Allen Posts: 6,664
    edited 2008-09-17 15:42
    I don't know if this is the issue, but initialize the program with LOW CLK in addition to LOW RTC. Without that, the clock pin can be in the wrong state when you first call the WRITE_RTC routine.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-09-17 19:58
    The following code might be clearer and would certainly remove the issues you’re having. I hope this helps. Take care.

    http://forums.parallax.com/showthread.php?p=531080

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • NR1XNR1X Posts: 111
    edited 2008-09-17 20:09
    AHH!! i didnt even think of that.. the whole rising edge vs falling edge thing...thanks ill try that and see if it makes a differance then ill update the thread again. it may be usefull for future stampers who run a search..
  • NR1XNR1X Posts: 111
    edited 2008-09-17 20:36
    thanks chris, i hadn't found that thread when i did a search.. great codes and they really would have helped a lot on the first day of experimenting.. im refining my code.. still have to disconnect power for a second or so before i can get Write_rtc to work i think i might try startin my code with outa and dira statements ill con tinue to play with it till it werks perfectly.. i wanted to starr from the ground up when i wrote the code.. i could have easily cut and pasted but wouldnt understand how it works.. now i did it myself and learned a little along the way.. again thank you
  • NR1XNR1X Posts: 111
    edited 2008-09-18 09:58
    Ok i got it working .. i feell kinna stupid, but an easy fix.. replaced battery and it writes flawlessly every time!!

    doh... ok so i attached my final code.. simple and straight forward as i could get it with the least variables i could think of.. thanks to all who helped
Sign In or Register to comment.