/** TIME.C ********************************************************** Zeit- und Datumsfunktionen benutzt die Funktion unsigned long gettime_s(void) aus Timer0 Die Funktion gettime_s() liefert die Anzahl der Sekunden seit 0:00 h *******************************************************************/ #include "time.h" #include "timer0.h" void timer0_debug(void) { unsigned long time = 10000; #ifdef __C51__ timer0_init(); #endif timer0_timeout_set_s(5); while (!timer0_timeout()) { } timer0_set(time); time += 100; while (timer0_get() #include void time_debug(void) { unsigned char testmode=2; unsigned long sec=0; unsigned char h,m,s; clrscr(); for (;;) { printf ("0:get/set_s 1:get/set_hms 2:input_hms 9:end\n"); testmode=getch(); switch (testmode) { case '9': return; case '0': printf("%li\n",time_get_s()); printf("set:1");if (getch()=='1') { printf("s:");scanf("%li",&sec);printf("\n"); time_set_s(sec); } break; case '1': time_set_hms(12,34,25); sec=time_get_s(); time_get_hms(&h,&m,&s); printf("%li 12:%2d 34:%2d 25:%2d\n",sec,h,m,s); break; case '2': { unsigned char c; unsigned long sek; unsigned int temp; sek=time_get_s(); time_get_hms(&h,&m,&s); printf("%li %2d:%2d:%2d\n",sek,h,m,s); printf("h:");scanf("%d",&temp);printf("\n");h=temp; printf("m:");scanf("%d",&temp);printf("\n");m=temp; printf("s:");scanf("%d",&temp);printf("\n");s=temp; time_set_hms(h,m,s); break; } default: break; } } } #endif /* /* __C51__ */ */ void main(void) { timer0_debug(); time_debug(); }