HELP! DS1307 issues [s](again)[/s] (still)
Chuck E.
Posts: 14
Hi gang,
I'm still learning, even if slowly. I'm having trouble setting my RTC on the Professional Development Board. Maybe some of you gurus can point out my error, I'm sure it'll be something obvious.
SDA is on 0, SCL on 1.
Here is what I did:
' {$STAMP BS2p}
DS1307 CON %1101 << 4
sec VAR Byte
minute VAR Byte
hour VAR Byte
day VAR Byte
date VAR Byte
month VAR Byte
year VAR Byte
'I2COUT 0, ds1307, 1, [noparse][[/noparse]DEC 20]
'I2COUT 0, ds1307, 2, [noparse][[/noparse]HEX 10]
'I2COUT 0, ds1307, 3, [noparse][[/noparse]DEC 05]
'I2COUT 0, ds1307, 4, [noparse][[/noparse]DEC 06]
'I2COUT 0, ds1307, 5, [noparse][[/noparse]DEC 07]
'I2COUT 0, ds1307, 6, [noparse][[/noparse]DEC 07]
main
I2CIN 0, DS1307, 1, [noparse][[/noparse]minute]
I2CIN 0, DS1307, 2, [noparse][[/noparse]hour]
I2CIN 0, DS1307, 3, [noparse][[/noparse]day]
I2CIN 0, DS1307, 4, [noparse][[/noparse]date]
I2CIN 0, DS1307, 5, [noparse][[/noparse]month]
I2CIN 0, DS1307, 6, [noparse][[/noparse]year]
DEBUG HEX sec, " seconds", CR
DEBUG HEX minute, " minutes", CR
DEBUG HEX hour, " hour", CR
DEBUG HEX day, " day", CR
DEBUG HEX date, " date", CR
DEBUG HEX month, " month", CR
DEBUG HEX year, " year", CR
PAUSE 100
DEBUG CLS
GOTO main
I borrowed this part: "DS1307 CON %1101 << 4" from a clock program from Stampworks, damfino if it's right, this might be part of the problem ¿Quíen sabe?
When I ran it the first time, it was at 10:20 this morning without the I2COUT statements commented out. I neglected to write down the output of the debug window, but it wasn't what I was expecting. I've since run it some more with the I2COUT stuff commented out, and what I got just a few minutes ago was:
0 seconds
88 minutes
65 hour
54 date
23 month
55 year
So fellas and fellowettes, what obvious thing am I missing/screwing up?
Chuck
Oh, yeah, RTC battery is installed, and I clear the stamp memory between running programs.
Post Edited (Chuck E.) : 7/6/2007 4:01:09 PM GMT
I'm still learning, even if slowly. I'm having trouble setting my RTC on the Professional Development Board. Maybe some of you gurus can point out my error, I'm sure it'll be something obvious.
SDA is on 0, SCL on 1.
Here is what I did:
' {$STAMP BS2p}
DS1307 CON %1101 << 4
sec VAR Byte
minute VAR Byte
hour VAR Byte
day VAR Byte
date VAR Byte
month VAR Byte
year VAR Byte
'I2COUT 0, ds1307, 1, [noparse][[/noparse]DEC 20]
'I2COUT 0, ds1307, 2, [noparse][[/noparse]HEX 10]
'I2COUT 0, ds1307, 3, [noparse][[/noparse]DEC 05]
'I2COUT 0, ds1307, 4, [noparse][[/noparse]DEC 06]
'I2COUT 0, ds1307, 5, [noparse][[/noparse]DEC 07]
'I2COUT 0, ds1307, 6, [noparse][[/noparse]DEC 07]
main
I2CIN 0, DS1307, 1, [noparse][[/noparse]minute]
I2CIN 0, DS1307, 2, [noparse][[/noparse]hour]
I2CIN 0, DS1307, 3, [noparse][[/noparse]day]
I2CIN 0, DS1307, 4, [noparse][[/noparse]date]
I2CIN 0, DS1307, 5, [noparse][[/noparse]month]
I2CIN 0, DS1307, 6, [noparse][[/noparse]year]
DEBUG HEX sec, " seconds", CR
DEBUG HEX minute, " minutes", CR
DEBUG HEX hour, " hour", CR
DEBUG HEX day, " day", CR
DEBUG HEX date, " date", CR
DEBUG HEX month, " month", CR
DEBUG HEX year, " year", CR
PAUSE 100
DEBUG CLS
GOTO main
I borrowed this part: "DS1307 CON %1101 << 4" from a clock program from Stampworks, damfino if it's right, this might be part of the problem ¿Quíen sabe?
When I ran it the first time, it was at 10:20 this morning without the I2COUT statements commented out. I neglected to write down the output of the debug window, but it wasn't what I was expecting. I've since run it some more with the I2COUT stuff commented out, and what I got just a few minutes ago was:
0 seconds
88 minutes
65 hour
54 date
23 month
55 year
So fellas and fellowettes, what obvious thing am I missing/screwing up?
Chuck
Oh, yeah, RTC battery is installed, and I clear the stamp memory between running programs.
Post Edited (Chuck E.) : 7/6/2007 4:01:09 PM GMT
Comments
Use HEX in all the I2Cout commands, not DEC.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
http://forums.parallax.com/showthread.php?p=660091
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Changed this:
I2COUT 0, ds1307, 1, [noparse][[/noparse]DEC 20]
To this:
'I2COUT 0, ds1307, 1, [noparse][[/noparse]$20]
And all was right with the world.
The link Chris points to is where I got most info needed, also the 1307 datasheet is a help for address info on the registers. I did learn something from all this, so it's not a total loss.
Chuck
So boyz -n- gurlz, would it work the same if I used BCD?
CE
' {$STAMP BS2p}
' DEBUG "Stamp clear."
' File created by Chuck E.
DS1307 CON %1101 << 4
sec VAR Byte
minute VAR Byte
hour VAR Byte
day VAR Nib
date VAR Byte
month VAR Byte
year VAR Byte
'Set I2COUT variables between the [noparse]/noparse to correct values just before running.
'Comment out with "'" at beginning of command line any that do not need to be
'updated. Comment out all I2COUT lines if you only want to see RTC time.
'Day: Sunday = 0, Monday = 1, Tuesday = 2, etc.
'I2COUT 0, ds1307, 1, [noparse][[/noparse]$41]
'I2COUT 0, ds1307, 2, [noparse][[/noparse]$08]
'I2COUT 0, ds1307, 3, [noparse][[/noparse]$03]
'I2COUT 0, ds1307, 4, [noparse][[/noparse]$11]
'I2COUT 0, ds1307, 5, [noparse][[/noparse]$07]
'I2COUT 0, ds1307, 6, [noparse][[/noparse]$07]
I2COUT 0, ds1307, 7, [noparse][[/noparse]$10] 'this line enables 1Hz output
'I2COUT 0, ds1307, 7, [noparse][[/noparse]$00] 'this line disables 1Hz output
main
I2CIN 0, DS1307, 0, [noparse][[/noparse]sec] 'gets seconds from RTC
I2CIN 0, DS1307, 1, [noparse][[/noparse]minute] 'gets minutes from RTC
I2CIN 0, DS1307, 2, [noparse][[/noparse]hour] 'gets hours from RTC
I2CIN 0, DS1307, 3, [noparse][[/noparse]day] 'gets day of week from RTC
I2CIN 0, DS1307, 4, [noparse][[/noparse]date] 'gets date from RTC
I2CIN 0, DS1307, 5, [noparse][[/noparse]month] 'gets month from RTC
I2CIN 0, DS1307, 6, [noparse][[/noparse]year] 'gets year from RTC
DEBUG HEX sec, "seconds", CR 'displays seconds in debug window
DEBUG HEX minute, "minutes", CR 'displays minutes in debug window
DEBUG HEX hour, "hour", CR 'displays hours in debug window
DEBUG HEX day, "day", CR 'displays day of week in debug window
DEBUG HEX date, "date", CR 'displays date in debug window
DEBUG HEX month, "month", CR 'displays month in debug window
DEBUG HEX year, "year", CR 'displays year in debug window
PAUSE 250 'delay between refreshes
DEBUG CLS, "RTC Clock Repeater", CR
GOTO main
Chuck