The DS1307 can be run in either 12-hour or 24-hour mode. Bit 6 of the hours register is defined as the 12-hour or
24-hour mode-select bit. When high, the 12-hour mode is selected. In the 12-hour mode, bit 5 is the AM/PM bit with
logic high being PM. In the 24-hour mode, bit 5 is the second 10-hour bit (20 to 23 hours).
The hours value must be re-entered whenever the 12/24-hour mode bit is changed.
I2C1_Init(100000) ' initialize full master mode
I2C1_Start() ' issue start signal
I2C1_Wr(0xD0) ' address DS1307
I2C1_Wr(0) ' start from word at address (REG0)
I2C1_Wr(0x80) ' write $80 to REG0. (pause counter + 0 sec)
I2C1_Wr(0x58) ' write 0 to minutes word to (REG1)
[B][COLOR=#ff0000] 'I2C1_Wr(0x51) ' write 11 AM to hours word (12-hours mode)(REG2)
' by setting bit6 of timekeeping register
'I2C1_Wr(0x71) ' write 11 PM to hours word (12-hours mode)(REG2)
' by setting bit6 and bit5 of timekeeping register
I2C1_Wr(0x11) ' write 11 to hours word (24-hours mode)(REG2)[/COLOR][/B]
I2C1_Wr(0x07) ' write 7 - Saturday (REG3)
I2C1_Wr(0x24) ' write 4 to date word (REG4)
I2C1_Wr(0x10) ' write 10 (October) to month word (REG5)
I2C1_Wr(0x09) ' write 09 to year word (REG6)
I2C1_Stop() ' issue stop signal
Thank you so much. This was the one I was and others looked for ...It is working.
Hints for your future:Thank you so much. This was the one I was and others looked for ...It is working.
This tells nothing what you really did, what you epected and what happened instead. Its useless for us to help you.I did all the codes you said, nothing happens.
This sets bit 6 of hour register (Addr2), and for sure clears the other 7 bits.write_ds1307(2,0x40)
Dear friend, I still struggling to get over the problem of changing between 12/24 hour modes.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?