View Full Version : Heads up.. found a minor glitch..bs2 and ds1302 rtc
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
09-17-2008, 10:42 PM
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.
09-18-2008, 02:58 AM
The following code might be clearer and would certainly remove the issues you’re having. I hope this helps. Take care.
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..
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
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