390
Platforms
©2000-2008 Tibbo Technology Inc.
Two methods of the RTC object-
and
are used to read
and set the counter value.
Supposing that your project has curr_year, curr_month, curr_date, curr_hours,
curr_minutes, and curr_seconds variables, here is how you set and get the time:
dim
curr_year, curr_month, curr_date, curr_hours, curr_minutes,
curr_seconds
as
byte
dim
x,y
as
word
...
...
'set RTC now (data is supposed to be prepared in curr_ variables)
rtc.set(daycount(curr_year,curr_month,curr_date),mincount(curr_hours,curr_
minutes),curr_seconds)
...
...
'get RTC now- first get the daycount and mincout into x and y
rtc.getdata(x,y,curr_seconds)
'now convert daycount and mincount into date and time
curr_year=year(x)
curr_month=month(x)
curr_date=date(x)
curr_hours=hours(y)
curr_minutes=minutes(y)
There is also
read-only property that tells you whether the RTC is
working.
Notice, that after the device powers up and provided that the backup
power was not present at all times the RTC may be in the
undetermined state and not work properly until the rtc.set method is
executed at least once. Incorrect behavior may include failure to
increment or incrementing at an abnormal rate. Rtc.running cannot be
used to reliably check RTC state in this situation.
It is not necessary to use rtc.set if the backup power was present at all
times while the device was off.
8.3.11.1
.Getdata Method (Previously .Get)
Function:
Returns current RTC data as the number of elapsed days,
minutes and seconds.
Syntax:
rtc.getdata(byref daycount as word, byref mincount
as word, byref seconds as byte)
Returns:
Number of elapsed days, minutes, and seconds. Notice
that this is done indirectly, through byref arguments.
See Also:
Part
Description
daycount
Number of elapsed days.
mincount
Number of elapsed minutes.
seconds
Number of elapsed seconds.
390
391
391
389