On Fri, Aug 21, 2009 at 01:13:17AM +0200, Groepaz wrote: > when reading the time, the current status of hour/min/sec/10th sec will get > latched when you read the hour, and the registers will no more change until > you read the 10th sec register. so simply read hour first, 10th sec last :) > (writing to the registers does not affect this behaviour btw) I know that. When writing to the registers, the clock will also stop and start again when writing to the 10th sec register. The code seems to be correct in this respect, this is the reason why I'm wondering. Here is a short test snippet. It reads the time from the TOD clock directly and via time(). With the write to tod_10 disabled, the clock does not run. It looks like someone/something has stopped the clock by writing to tod_hour before, because the program works ok when the write is enabled. ----------------------------------------------------------------------------- #include <stdio.h> #include <time.h> #include <cbm.h> static unsigned char bcdtoa (unsigned char x) { return (x & 0x0F) + (x >> 4) * 10; } int main(void) { time_t T; unsigned char hour, min, sec, sec10; /* CIA1.tod_10 = 0; */ while (1) { hour = CIA1.tod_hour; min = CIA1.tod_min; sec = CIA1.tod_sec; sec10 = CIA1.tod_10; printf ("%02d:%02d:%02d\n", bcdtoa (hour), bcdtoa (min), bcdtoa (sec)); T = time (0); printf ("%s\n", asctime (localtime (&T))); } } ----------------------------------------------------------------------------- Tested with VICE 1.19 - not on a real machine. Regards Uz -- Ullrich von Bassewitz uz@musoftware.de ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Fri Aug 21 13:16:04 2009
This archive was generated by hypermail 2.1.8 : 2009-08-21 13:16:06 CEST