CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Changing the ds1307 time format and adjusting the time

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
muralid



Joined: 13 Oct 2015
Posts: 9

View user's profile Send private message

Changing the ds1307 time format and adjusting the time
PostPosted: Fri Oct 16, 2015 4:17 am     Reply with quote

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: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Oct 16, 2015 5:04 am     Reply with quote

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: 19504

View user's profile Send private message

PostPosted: Fri Oct 16, 2015 6:53 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Oct 16, 2015 11:28 pm     Reply with quote

There's a modified version of the ds1307 driver in the Code Library that
has support for am/pm. I have not tested it. See the link below:
http://www.ccsinfo.com/forum/viewtopic.php?t=50408
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group