QuickBASIC Example:
'$INCLUDE: 'RTC_API.BI' | ‘Must be first executed statement in your program |
DIM timeS AS TimeSaveT | ‘Define Variable Structure |
DIM time AS GetTimeT |
|
address% = StartRTCAPI(0) | ‘Initialize API |
IF (address% <> 0) THEN | ‘Check that it initialized OK |
IF (GetRTCTime(VARSEG(time), VARPTR(time)) <> 0) THEN | |
PRINT “RTC time: “; time.hours; “:”; time.min; “:”; time.seconds; “.”; | |
PRINT time.hseconds |
|
END IF |
|
IF (LastPowerDownRTC(VARSEG(timeS), VARPTR(timeS)) <> 0) THEN | |
PRINT "Last Power Down (Reset): "; timeS.month; "/"; timeS.day; | |
PRINT "at"; timeS.hour; ":"; timeS.minute; ":"; timeS.second | |
END IF |
|
IF (BatteryRTC) THEN | ‘Check Battery Status |
PRINT "Battery Status: GOOD"
ELSE
PRINT "Battery Status: LOW"
END IF
ELSE
PRINT "Device Driver (PCRTCDD.SYS) must be loaded."
END IF
END
Pascal Programming Example
USES RTC_API;
VAR ts: TimeSave_Ptr; time: GetTime_Ptr; address: WORD; battery: WORD;
BEGIN
New(ts);
New(time);
address := Start_RTC_API(0); IF (address <> 0) THEN
BEGIN
IF (Get_RTC_Time(time) <> 0) THEN
writeln(‘RTC time: ‘, time^.hours, ‘:’, time^.min, ‘:’, time^.second, ‘.’, time^.hseconds);
IF (Last_Power_Down_RTC(ts) <> 0) THEN
writeln('Last Power Down (Reset): ', ts^.month, '/', ts^.day, ' at ', ts^.hour, ':', ts^.minute, ':', ts^.second);
IF (Battery_RTC <> 0) THEN writeln('Battery Status: Good')
ELSE writeln('Battery Status: Low');
END
ELSE writeln('Device Driver (PCRTCDD.SYS) must be installed.'); Dispose(ts);
Dispose(time);
END.
10 | Documentation Number PCRTC2095 Manual |
B&B Electronics | PO Box 1040 |
PH (815)