B&B Electronics PCRTC manual QuickBASIC Example, Pascal Programming Example

Page 12

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 -- Ottawa, IL 61350

PH (815) 433-5100 -- FAX (815) 433-5105

Image 12
Contents Electronics Mfg. Co. Inc Designed and Manufactured Ottawa, IllinoisInternet Table of Contents Specifications General InformationIntroduction Packing ListSetup Hardware SetupHardware Installation Software SetupUsing the Device Driver OperationOverview Command Line Options Setting the Pcrtc Time and DateReplacing the battery Programming with the PcrtcBatteryRTC StartRTCAPIGetRTCTime WordLastPowerDownRTC QuickBASIC Example Pascal Programming ExampleProgramming Example Calculating Error Oscillator ErrorPPM Terminology Aging Appendix A. Hardware I/O Map Map of XT Class MachinesHardware I/O Map of AT Class Machines