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

Auto update Real time with Ds1302?

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



Joined: 21 Oct 2012
Posts: 8

View user's profile Send private message Yahoo Messenger

Auto update Real time with Ds1302?
PostPosted: Sun Nov 29, 2015 3:31 am     Reply with quote

Hi All!
I use DS1302 to read time. But i want to auto update time when my circuit start but not setup time.
Please tell me can i do it?
Thanks?
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sun Nov 29, 2015 4:26 am     Reply with quote

Just call rtc_init, then read the time with rtc_get_date & rtc_get_time.

Provided the battery backup is correctly attached, the chip will have kept running. You'd ll need a way to call rtc_set_datetime, at some point when you _do_ want to adjust the date and time.

Look at the example ex_rtc.c
This does exactly this. You sit in a loop waiting for either 'S' (to set/change), or 'D' (to display the time). Wake it up, use 'S' to set the clock, then power the PIC down. Then re-power it, and use 'D'. You will see the clock still running counting from the value you set when you typed 'S'.
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