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

Current Time from PC

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



Joined: 14 Jan 2015
Posts: 18
Location: Christchurch New Zealand

View user's profile Send private message

Current Time from PC
PostPosted: Mon May 25, 2015 5:09 pm     Reply with quote

Hi All, Is there a way to use the __TIME__ function of the compiler to extract the current time and use the data to set up say a DS1307?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 25, 2015 6:51 pm     Reply with quote

It only works at compile time. It doesn't work at runtime. And indeed at
runtime, you would need some connection between the PIC and a PC to
get the time by any method.
MarkchchPIC



Joined: 14 Jan 2015
Posts: 18
Location: Christchurch New Zealand

View user's profile Send private message

PostPosted: Mon May 25, 2015 8:19 pm     Reply with quote

Thanks PCM,

So if I have a serial connection to the PC I could setup and send a string in the format hhmmss then read at the PIC and update the DS1307?
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Mon May 25, 2015 9:32 pm     Reply with quote

Of course, but the compiler won't do that for you. You have to write a PC program to send the current time as a string when prompted or maybe once per minute. Or maybe you can find a freeware program that does that.

Either way, that's only half the battle. You'd also need to add PIC code to a) catch the string, b) parse/interpret the string, and c) properly write present time to the DS1307.
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