Having trouble getting Seiko RTC working on Propeller DNA board
Don M
Posts: 1,652
I have copied some of the code that Beau wrote for the Spinneret but can't seem to make it work. It just shows "Mon Jan 01, 2012 12:00:00 AM". Once it's started the clock counts up but I can't seem to set the time.
Here's my main code:
Any help appreciated.
Thanks
Don
Here's my main code:
con _clkmode = xtal1 + pll16x _clkfreq = 80_000_000 MS_001 = 80_000_000 / 1_000 obj term : "fullduplexserialplusdecn" ' for terminal output clock : "s-35390A_GBSbuild_02_09_2011" ' Seiko RTC driver var long MM_DD_YYYY, DW_HH_MM_SS byte dig2[2] pub main | d, l ,s term.start(31, 30, %0000, 115_200) ' start terminal (use PST) clock.start pause(1000) term.tx(0) term.str(@version) repeat d := term.rxcheck case d "c": SetClock "t": term.str(clock.FmtDateTime) term.tx(13) pub SetClock Prompt(String("Enter year (2000-2099)"),true) MM_DD_YYYY[0] := getSerVal(4) Prompt(String("Enter month (01-12)"),true) MM_DD_YYYY[3] := getSerVal(2) Prompt(String("Enter date (01-31)"), true) MM_DD_YYYY[2] := getSerVal(2) Prompt(String("Enter day of week where 0=SUN 1=MON 2=TUE 3=WED 4=THU 5=FRI 6=SAT"), true) DW_HH_MM_SS[3] := getSerVal(1) Prompt(String("Enter hour 0-23 "),true) DW_HH_MM_SS[2] := getSerVal(2) Prompt(String("Enter minute (01-59)"),true) DW_HH_MM_SS[1] := getSerVal(2) DW_HH_MM_SS[0] := 0 ' Set seconds to 0 clock.SetDateTime(byte[@MM_DD_YYYY][3], { <- Month } byte[@MM_DD_YYYY][2], { <- Day } word[@MM_DD_YYYY][0] - 2000, { <- Year } byte[@DW_HH_MM_SS][3], { <- (day of week) } byte[@DW_HH_MM_SS][2], { <- Hour } byte[@DW_HH_MM_SS][1], { <- Minutes } byte[@DW_HH_MM_SS][0]) { <- Seconds } term.tx(13) term.str(clock.FmtDateTime) pub getSerVal(lim) : value | bytesread, tmp, x, place term.RxFlush bytesread := 0 value := 0 place := 1 repeat while bytesread < lim tmp := term.Rx if ((tmp == 10) OR (tmp ==13) OR (tmp == "*")) QUIT if (tmp => ("0")) and (tmp =< ("9")) dig2[bytesread] := tmp bytesread++ repeat x from (bytesread - 1) to 0 value := value + ((dig2[x]-"0") * place) place := place * 10 pub pause(ms) | t t := cnt repeat ms waitcnt(t += MS_001) pri Prompt(msg, CR) term.str(msg) if CR term.tx(13) dat version byte "DNA Board Clock Play", 13, 0
Any help appreciated.
Thanks
Don
Comments
For the year (occupying 2 bytes) use MM_DD_YYYY.word[0] instead.
kuroneko- Thanks so much! As always you are a great help in learning this stuff.
New code below: