Ds1307
Newzed
Posts: 2,503
Does anyone know if there is a N&V column on operating the DS1307 with a BS2, or any other source.· I have a program which I thought was OK but can't get it to work so I just wanted to check it against a working program.
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Visit the Piggyback Page
http://hometown.aol.com/newzed/index.html
·
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Visit the Piggyback Page
http://hometown.aol.com/newzed/index.html
·
Comments
BTW, I'm writing about I2C in my November column, and the DS1307 will be included.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Visit the Piggyback Page
http://hometown.aol.com/newzed/index.html
·
I'll let it run for a bit, and then if everything seems OK, I'll post the HEX2 format code here.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Visit the Piggyback Page
http://hometown.aol.com/newzed/index.html
·
Please be aware that this is a modification of the original BS2 I2C code for the 1307.· You should have no problems with it, but if something should arise, please contact me since this is my responsibility.
I think you will find that this code runs a bit faster than the BCD version, and it will save you over 200 bytes of program space.· It uses Stamp I/O ports 8 and 9, but these maybe changed to 0 and 1 if you prefer.· Standard I2C protocol requires the use of 0/1 or 8/9 so it is suggested you use these ports just to conform.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Visit the Piggyback Page
http://hometown.aol.com/newzed/index.html
Your Get_Clock and Set_Clock routines could be shortened by using a loop and indexing from the minutes register.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Post Edited (Jon Williams) : 9/9/2004 3:17:34 PM GMT
Put_Clock:
·GOSUB I2C_Start
· i2cWork = Wr1307
· GOSUB I2C_TX_Byte
· i2cWork = 0
· GOSUB I2C_TX_Byte
· FOR idx = 0 TO 5
· LOOKUP idx, [noparse][[/noparse]seconds, minutes, hours, day, date, month, year], i2cwork
· GOSUB I2C_TX_Byte
· NEXT
· GOSUB I2C_Stop
· RETURN
I tried doing the Get_Clock but since that is backwards to Put_Clock I couldn't figure out how to do it.· I wrote:
Get_Clock:
· GOSUB I2C_Start
· i2cWork = Wr1307
· GOSUB I2C_TX_Byte
· i2cWork = 0
· GOSUB I2C_TX_Byte
· GOSUB I2C_Start
· i2cWork = Rd1307
· GOSUB I2C_TX_Byte
· FOR idx = 0 TO 5
· GOSUB I2C_RX_Byte
· LOOKDOWN i2cwork, [noparse][[/noparse]seconds, minutes, hours, day, date, month]
· NEXT
· GOSUB I2C_RX_Byte_Nak························ ' final byte - send NAK
· year = i2cWork······························· 'year
· GOSUB I2C_Stop
· RETURN
but I really don't think that will work.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Visit the Piggyback Page
http://hometown.aol.com/newzed/index.html
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Sid
http://forums.parallax.com/forums/default.aspx?f=5&m=2373&g=2443#m2443
My N&V code has new (clearer) variable names and will allow the user to use buttons to reset the clock, or to change the time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Sid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Visit the Piggyback Page
http://hometown.aol.com/newzed/index.html
·
Let me clarify·.. Your software is trying to work.· The Time Set/Read menu comes up.
The data returned on a read is only 0's.
I gave up guessing if I had the magic crystal... wanting to·eliminate another variable... But with an externally 32.7 Khz clock on Pin 1, its still not working.
Anyone know how to get these to show some sign of life?· I bought 4 new parts·which were well protected from static...
Thanks
Post Edited (GaryM) : 9/14/2004 12:33:34 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The chip lives !
Embarassing electrical fault. Fixed *S*
Two questions now:
Why on earth is this thing counting in Hex?· Changing it to output "DEC2" doen'st make it produce resonable numbers, either.· I tried Sid's code first then Jon's.· Both have hex outputs???
And how does one set the square wave output?·