View previous topic :: View next topic |
Author |
Message |
MarkchchPIC
Joined: 14 Jan 2015 Posts: 18 Location: Christchurch New Zealand
|
Current Time from PC |
Posted: Mon May 25, 2015 5:09 pm |
|
|
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
|
|
Posted: Mon May 25, 2015 6:51 pm |
|
|
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
|
|
Posted: Mon May 25, 2015 8:19 pm |
|
|
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: 1909
|
|
Posted: Mon May 25, 2015 9:32 pm |
|
|
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. |
|
|
|