Experiment #33 in StampWorks Manual (DS1307 RTC) need code for updating Year an
Migs
Posts: 95
Friends:
I have set up and run Experiment #33 in the StampWorks Manual involving the Professional Development Board and the DS1307 Real Time Clock, a BS2P40 Module and software SW21-EX33-DS1307.BSP
1. Does anyone have modified code for displaying and updating with the complete 4 digit year? (and the wiring schematic?)
2. Does anyone have code for writing this information to the 7 Segment LED display on the Professional Development Board?
I remain most grateful,
Migs
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Sometimes we forget that the world itself is paradise." Douglas Coupland, 'Microserfs'
"If the doors of perception were cleansed every thing would appear to man as it is, infinite" - William Blake
"We either make ourselves miserable, or we make ourselves strong. The amount of work is the same." Carlos Castaneda
"One single grateful thought raised to heaven is the most perfect prayer. " G. E. Lessing
“How much of human life is lost in waiting.” Ralph Waldo Emerson
"Men often mistake notoriety for fame, and would rather be remembered for their vices and follies than not be noticed at all.” Harry Truman
My website: www.intoku.net my e-mail:mreznicek@pretensa.com me:Miguel Reznicek
Post Edited (Migs) : 7/17/2010 10:45:41 PM GMT
I have set up and run Experiment #33 in the StampWorks Manual involving the Professional Development Board and the DS1307 Real Time Clock, a BS2P40 Module and software SW21-EX33-DS1307.BSP
' ========================================================================= ' ' File....... SW21-EX33-DS1307.BSP ' Purpose.... Real-time-clock interfacing ' Author..... (C) 2000 - 2005, Parallax, Inc. ' E-mail..... support@parallax.com ' Started.... ' Updated.... 16 AUG 2006 ' ' {$STAMP BS2p} ' {$PBASIC 2.5} ' ' ========================================================================= ' -----[noparse][[/noparse] Program Description ]--------------------------------------------- ' ' This program demonstrates the access and control of an external real- ' time-clock chip, the DS1307. ' -----[noparse][[/noparse] I/O Definitions ]------------------------------------------------- SDA PIN 0 ' I2C serial data line SCL PIN 1 ' I2C serial clock line BtnBus VAR INB ' four inputs, pins 4 - 7 ' -----[noparse][[/noparse] Constants ]------------------------------------------------------- Ack CON 0 ' acknowledge bit Nak CON 1 ' no ack bit DS1307 CON %1101 << 4 ' -----[noparse][[/noparse] Variables ]------------------------------------------------------- secs VAR Byte ' DS1307 time registers mins VAR Byte hrs VAR Byte day VAR Byte ' weekday date VAR Byte ' day in month, 1 - 31 month VAR Byte year VAR Byte control VAR Byte ' SQW I/O control btns VAR Nib ' debounced button inputs btnBack VAR btns.BIT3 ' roll back btnDay VAR btns.BIT2 ' +/- day btnHr VAR btns.BIT1 ' +/- hours btnMn VAR btns.BIT0 ' +/- minutes idx VAR Nib ' loop control pntr VAR Byte ' ee pointer char VAR Byte ' character for display ' -----[noparse][[/noparse] EEPROM Data ]----------------------------------------------------- DayNames DATA "SunMonTueWedThuFriSat" ' -----[noparse][[/noparse] Initialization ]-------------------------------------------------- Reset: #IF ($STAMP < BS2P) #THEN #ERROR "Please use BS2 version: SW21-EX33-DS1307.BS2" #ENDIF Setup: DEBUG CLS, "DS1307 Demo", CR, "-----------" Reset_Clock: GOSUB Get_Buttons ' scan buttons idx = btns & %0011 ' isolate hrs & mins IF (idx = %11) THEN ' if both pressed, reset secs = $00 mins = $00 hrs = $06 ' 6:00 AM day = $07 ' Saturday date = $01 ' 1st month = $01 ' January year = $05 ' 2005 control = 0 ' disable SQW output GOSUB Set_Clock ' block write clock regs ENDIF ' -----[noparse][[/noparse] Program Code ]---------------------------------------------------- Main: GOSUB Get_Clock ' read DS1307 hrs = hrs & $3F DEBUG CRSRXY, 0, 2, HEX2 hrs, ":", HEX2 mins, ":", HEX2 secs, CR GOSUB Print_Day PAUSE 100 GOSUB Get_Buttons IF (btns > %0000) THEN ' button pressed? IF (btns <> %1000) THEN ' ignore back only hrs = hrs.NIB1 * 10 + hrs.NIB0 ' BCD to decimal mins = mins.NIB1 * 10 + mins.NIB0 IF (btnBack = 0) THEN ' increment values day = ((day - 1) + btnDay // 7) + 1 ' keep 1 - 7 hrs = hrs + btnHr // 24 ' keep 0 - 23 mins = mins + btnMn // 60 ' keep 0 - 59 ELSE day = ((day - 1) + (btnDay * 6) // 7) + 1 hrs = hrs + (btnHr * 23) // 24 mins = mins + (btnMn * 59) // 60 ENDIF hrs = (hrs / 10 << 4) + (hrs // 10) ' decimal to BCD mins = (mins / 10 << 4) + (mins // 10) secs = $00 GOSUB Set_Clock ' update DS1307 ENDIF ENDIF GOTO Main ' -----[noparse][[/noparse] Subroutines ]----------------------------------------------------- Get_Buttons: btns = %1111 ' enable all four inputs FOR idx = 1 TO 5 btns = btns & ~BtnBus ' test inputs PAUSE 5 ' delay between tests NEXT RETURN Print_Day: pntr = DayNames + ((day - 1) * 3) ' point to 1st char FOR idx = 0 TO 2 ' print 3 letters READ (pntr + idx), char ' read letter DEBUG char ' print it NEXT RETURN ' Do a block write to clock registers Set_Clock: I2COUT SDA, DS1307, 0, [noparse][[/noparse]STR secs\8] ' update clock registers RETURN ' Do a block read from clock registers Get_Clock: I2CIN SDA, DS1307, 0, [noparse][[/noparse]STR secs\8] ' retrieve clock registers RETURN
1. Does anyone have modified code for displaying and updating with the complete 4 digit year? (and the wiring schematic?)
2. Does anyone have code for writing this information to the 7 Segment LED display on the Professional Development Board?
I remain most grateful,
Migs
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Sometimes we forget that the world itself is paradise." Douglas Coupland, 'Microserfs'
"If the doors of perception were cleansed every thing would appear to man as it is, infinite" - William Blake
"We either make ourselves miserable, or we make ourselves strong. The amount of work is the same." Carlos Castaneda
"One single grateful thought raised to heaven is the most perfect prayer. " G. E. Lessing
“How much of human life is lost in waiting.” Ralph Waldo Emerson
"Men often mistake notoriety for fame, and would rather be remembered for their vices and follies than not be noticed at all.” Harry Truman
My website: www.intoku.net my e-mail:mreznicek@pretensa.com me:Miguel Reznicek
Post Edited (Migs) : 7/17/2010 10:45:41 PM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Here is an application from another post that explains why the year is not dealt with in the listing above:
http://forums.parallax.com/forums/default.aspx?f=5&m=461713
Migs
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Sometimes we forget that the world itself is paradise." Douglas Coupland, 'Microserfs'
"If the doors of perception were cleansed every thing would appear to man as it is, infinite" - William Blake
"We either make ourselves miserable, or we make ourselves strong. The amount of work is the same." Carlos Castaneda
"One single grateful thought raised to heaven is the most perfect prayer. " G. E. Lessing
“How much of human life is lost in waiting.” Ralph Waldo Emerson
"Men often mistake notoriety for fame, and would rather be remembered for their vices and follies than not be noticed at all.” Harry Truman
My website: www.intoku.net my e-mail:mreznicek@pretensa.com me:Miguel Reznicek
Post Edited (Migs) : 7/18/2010 1:41:08 AM GMT
should print out the four digit date.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Thanks for your help!
Migs
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Sometimes we forget that the world itself is paradise." Douglas Coupland, 'Microserfs'
"If the doors of perception were cleansed every thing would appear to man as it is, infinite" - William Blake
"We either make ourselves miserable, or we make ourselves strong. The amount of work is the same." Carlos Castaneda
"One single grateful thought raised to heaven is the most perfect prayer. " G. E. Lessing
“How much of human life is lost in waiting.” Ralph Waldo Emerson
"Men often mistake notoriety for fame, and would rather be remembered for their vices and follies than not be noticed at all.” Harry Truman
My website: www.intoku.net my e-mail:mreznicek@pretensa.com me:Miguel Reznicek