/* DT.c: Reading the date and time from a RTC and print it on a monitor (user can set the date and time). Compiler: BC++ 3.1, Turbo C++ 1.01 (3.01) MSVC 1.52 Compile mode: Large Project: DT.c ..\Lib\upac5000.lib Hardware: uPAC-5000 [Dec 28, 2011] by Liam */ #include #include "..\lib\upac5000.h" void main(void) { int year, month, day, hour, min, sec; int oyear, omonth, oday, ohour, omin, osec; int quit=0; InitLib(); oyear=omonth=oday=ohour=omin=osec=-1; Print("Start dt.exe (Press q to stop program)\r\n"); while(!quit) { if(Kbhit()) { switch(Getch()) { case 'q': quit=1; break; case 'd': SetDate(2000, 2, 29); // set date to 02/29/2000 break; case 't': SetTime(23, 59, 0); break; case 'y': SetDate(2000, 2, 28); // set date to 02/28/2000 SetTime(23, 59, 0); break; default: break; } } GetDate(&year, &month, &day); GetTime(&hour, &min, &sec); if(oyear!=year || omonth!=month || oday!=day || ohour!=hour || omin!=min || osec!=sec) { oyear=year; omonth=month; oday=day; ohour=hour; omin=min; osec=sec; Print("Date=%02d/%02d/%04d Time=%02d:%02d:%02d\n\r", month, day, year, hour, min, sec); } } }