View previous topic :: View next topic |
Author |
Message |
muralid
Joined: 13 Oct 2015 Posts: 9
|
Changing the ds1307 time format and adjusting the time |
Posted: Fri Oct 16, 2015 4:17 am |
|
|
Hi guys
I have interfaced the ds1307 with my pic 16f877a and it is displaying the time correctly. The issue is i want to change the time format to 12 hours format and i need to adjust the time using the pic. I have read the data sheet of ds1307 and it says to use the control registers for that, but i dont know how to access the registers.
Guys kindly help.... If possible please send me that piece of code. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Fri Oct 16, 2015 5:04 am |
|
|
Just look at the DS1307 driver and see which registers are used for date and time values. I think #6 is the one for 'time format'. It's been years since I used it..and not on the PC with the compiler.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Fri Oct 16, 2015 6:53 am |
|
|
If you are using the standard driver on the forum, then ds1307_set_date_time, will set the clock.
On 12 versus 24 hours, it's bit 6 of the _hours_ register, not a separate control. In the routine to set the clock, turn this bit on, before sending the hours value. Bit 5, is then the AM/PM indicator bit when the value is read.
If your data sheet says it is in the control register, then you are reading the wrong sheet.... The control register just enables the square wave output, and sets the rate of this. Quote:
"The DS1307 can be run in either 12-hour or 24-hour mode. Bit 6 of the
hours register is defined as the 12- 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-23 hours)." |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|