Shop OBEX P1 Docs P2 Docs Learn Events
bs2p w/ 1307 in 12hr mode — Parallax Forums

bs2p w/ 1307 in 12hr mode

The Lazy DestroyerThe Lazy Destroyer Posts: 21
edited 2005-12-30 13:38 in BASIC Stamp
Hi guys, I whipped up a quick program to change the time/date of a 1307 I have on I2C for my 2P40.

Everything works but I cannot seem to get it into 12 hr mode.

The code snippet:

idx VAR Byte
sec VAR Byte(6)

sec(0)=$50 'seconds
sec(1)=$59 'minutes
sec(2)=$12 'hour


FOR idx = 0 TO 6
I2COUT 0,%11010000,idx,[noparse][[/noparse]sec(idx)]
NEXT

This successfully writes: 12:59:50 (I cropped the date section of my code FYI)

into the correct registers, and then it runs up to the 13 hour. Documentation states that putting bit 6 of the hour register HIGH puts it into 12 hour mode. Does this mean I have to send it %01010010 instead of the normal %00010010? Cause that isn't working, but that is how I am reading the instructions.

I'm obviously doing something wrong, having tried different formats of setting that bit6 high. I tried searching here but the search function didn't really do much of anything for me.

1307 documentation can be seen here: www.sparkfun.com/datasheets/Components/DS1307.pdf

(bottom of page 4 and top of page 5)

Comments

  • The Lazy DestroyerThe Lazy Destroyer Posts: 21
    edited 2005-12-29 18:39
    Surfing while on my lunchbreak I found this lab online:

    http://www.sfu.ca/phys/430/Lab6.pdf·(middle of page 2)

    and it looks like they are in fact sending the %01010010 to the hour register for 12-hour mode and programming the hour to 12. I remember just sending it in binary altho they send it in BCD, it shouldn't matter I'm sure. So if I'm programming it the way I'm supposed to, am I just reading the registers wrong? I would think it shouldn't matter and when in 12-hour mode it just resets it back to 1 instead of 13. I haven't read anything about reading it different when in the different modes...
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2005-12-30 13:38
    The datasheet --

    attachment.php?attachmentid=39947
    644 x 574 - 67K
Sign In or Register to comment.