B&B Electronics PCRTC manual Programming Example

Page 13

C Programming Example

#include <conio.h> #include "rtc_api.h"

void main() {

TimeSave_T *ts = (TimeSave_T *) malloc(sizeof(TimeSave_T)); GetTime_T *time = (GetTime_T *) malloc(sizeof(GetTime_T));

unsigned int battery; unsigned int address;

cprintf("Demo (PCRTC-c) v1.00, (c) Copyright 1994, B&B Electronics Mfg. Co.\r\n\r\n");

address = Start_RTC_API(0); if (address) {

if (Get_RTC_Time(time))

cprintf(“RTC time: %u:%u:%u.%u\r\n”, time->hours, time->min, time>seconds, time->h_seconds);

if (Last_Power_Down_RTC(ts))

cprintf("Last Power Down (Reset): %.2u/%.2u at %u:%.2u:%.2u\r\n", ts->month, ts->day, ts->hour, ts->minute, ts->second);

if (Battery_RTC()) cprintf("Battery Status: Good\r\n");

else cprintf("Battery Status: Low\r\n");

}else cprintf("Device Driver (PCRTCDD.SYS) must be installed.\r\n"); free(ts);

free(time);

}

Documentation Number PCRTC2095 Manual

11

B&B Electronics -- PO Box 1040 -- Ottawa, IL 61350

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

Image 13
Contents Designed and Manufactured Ottawa, Illinois Electronics Mfg. Co. IncInternet Table of Contents General Information SpecificationsIntroduction Packing ListHardware Setup SetupSoftware Setup Hardware InstallationOperation Using the Device DriverOverview Setting the Pcrtc Time and Date Command Line OptionsProgramming with the Pcrtc Replacing the batteryStartRTCAPI BatteryRTCWord GetRTCTimeLastPowerDownRTC Pascal Programming Example QuickBASIC ExampleProgramming Example Oscillator Error Calculating ErrorPPM Terminology Aging Map of XT Class Machines Appendix A. Hardware I/O MapHardware I/O Map of AT Class Machines