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

Page 13
Image 13
B&B Electronics PCRTC manual Programming Example