Shop OBEX P1 Docs P2 Docs Learn Events
ds1307 clock w/ jm_ds1307_demo.spin — Parallax Forums

ds1307 clock w/ jm_ds1307_demo.spin

stargazer2050stargazer2050 Posts: 89
edited 2013-11-06 21:46 in Accessories
Ds1307 board from sparkfun
Quickstart board
Need fullduplexserial.spin
Jm_ds1307_demo.spin
5v, 4.7k pullups to 3.3v

Clock is running.
Took the apostraphe off of setclock at startup.
Clock sets, how to set todays time into it?
"copy block at pntr".....? Cant make out what that means.

So i guess i just need to know how to use this spin file better

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-11-06 08:41
    I am unclear about what you're trying to do, but if you're trying to use FullDuplexSerial.spin to communicate with the DS1307 that won't work. The DS1307 is an I2C device and requires an I2C object. I am not familiar with Jm_ds1307_demo and you didn't attach any code or link any objects you're using so there's no way to be sure.
  • stargazer2050stargazer2050 Posts: 89
    edited 2013-11-06 09:20
    Hi,

    Clock is working, the demo uses, full duplex and a i2c driver.
    Just need instruction on file usage to set the clock.

    Ive tried a bunch of other software but each either doesnt work the clock, or the use vga, lcd, or mirror duplex.
    Or sda and clk are set on 28 and 29 which are somewhere else on quickstart header.
  • stargazer2050stargazer2050 Posts: 89
    edited 2013-11-06 09:50
    pub set_time(sc, mn, hr) '' Set seconds, minutes, and hours registers sc := 0 #> hr <# 59 mn := 0 #> hr <# 59 hr := 0 #> hr <# 23 i2c.putpage(DS1307, RTC_SECS, 3, @sc)

    Need code pasting instructions

    Need file attachment instruction
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-11-06 10:24
    It would be a lot easier to offer help if we had a link to the object in question.

    As you know, I'm not averse to helping out or even testing software on my own setup.

    But I am too lazy to search for an object myself.
  • stargazer2050stargazer2050 Posts: 89
    edited 2013-11-06 10:30
    I know and ive got the files but cant seem to do it all on this android. Workin on it
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-11-06 10:40
    Darn, I'm not as lazy as I thought.

    Here's a link. It looks like it was attached to some forum post.

    I have a link to a tutorial by Phil on how to post code in post #3 of my index.

    Darn my lack of laziness. Here's the link.

    attachment.php?attachmentid=78421&d=1297987572
  • stargazer2050stargazer2050 Posts: 89
    edited 2013-11-06 10:42
    pub settime(sc, mn, hr)
    '' Set seconds, minutes, and hours registers
      sc := 0 #> hr <# 59
      mn := 0 #> hr <# 59  
      hr := 0 #> hr <# 23
      i2c.putpage(DS1307, RTC_SECS, 3, @sc)
    
    pub setdate(dy, dt, mo, yr)
      dy := 1 #> dy <# 7
      dt := 1 #> dt <# 31
      mo := 1 #> mo <# 12
      yr := yr // 100
      i2c.putpage(DS1307, RTC_DAY, 4, @dy)
      
    pub setclock(pntr)
    '' Copy block at pntr to DS1307
      i2c.putpage(DS1307, RTC_SECS, 8, pntr)
    
    
    
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-11-06 10:44
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-11-06 11:26
    The parameters being sent to the RTC or being read from the RTC are stored in the eight byte array "clock".

    The main method used "getclock" to read the values from the RTC and store them in the "clock" array with this command.
    getclock(@clock)
    

    It keeps doing this until the seconds value has changed.
    until (clock[RTC_SECS] <> last)
    

    Since "RTC_SECS" has been set to zero in the constant section, it's save to assume "clock[0]" holds the seconds.

    Once the seconds value no longer matches its previous value the program displays the new time.

    The "@" symbol is used to indicate a memory address rather then the value stored at that address. Passing an address is way of passing (or receiving) multiple parameters at once.
  • bee_manbee_man Posts: 109
    edited 2013-11-06 21:46
    Took the apostraphe off of setclock at startup.
    Clock sets, how to set todays time into it?

    Do you just want to set the RTC?

    You need to put your current time and date data after Preset
    dat
    
    PreSet          byte    $45, $59, $23, $03, $31, $12, $10, 0
    
    

    PreSet byte seconds, minutes, hours, day of week, day, month, year, 0

    Then put the apostrophe back in front of the setclock call so you won't keep loading the old data each time it runs.
Sign In or Register to comment.