4 ms·
TOTP without a real time clock is ambitious :)
by tyingq 4y ago
TOTP without a real time clock is ambitious :)
- classichasclass 4y ago(author) The CIA TOD clock is okay for this. It uses wall mains voltage, so it's about as accurate as your average office clock. You can use a CMD-compatible device to seed the time; I'll be adding Ultimate-II+ support as soon as it's off backorder.
- WirelessGigabit 4y agoDo you need to configure the Hz? Otherwise it'll run faster in the USA va Europe.
- layer8 4y agoSee here: http://codebase64.org/doku.php?id=base:initialize_tod_clock_on_all_platforms http://codebase64.org/doku.php?id=base:initialize_tod_clock_... I don’t understand it completely, so would appreciate an explanation.
- classichasclass 4y ago(author) Yes, it accounts for 50Hz vs 60Hz, see https://github.com/classilla/totp-c64/blob/main/totp.xa#L129 https://github.com/classilla/totp-c64/blob/main/totp.xa#L129 . Basically it uses the other CIA as a cycle counter to see how many cycles elapse between TOD ticks, and then adjusts accordingly (from https://codebase64.org/doku.php?id=base:efficient_tod_initialisation https://codebase64.org/doku.php?id=base:efficient_tod_initia... ).
- garaetjjte 4y ago>about as accurate as your average office clock That's underselling it, mains frequency is deliberately controlled to keep average frequency very accurately in long-term periods.
- classichasclass 4y agoRight, but this uses a 30-second period, which could be affected by smaller variations. In this case the use of the TOD is unavoidable because if I used the Timer A interrupt (50Hz or 60Hz depending on video standard), it would be slowed when interrupts were disabled for doing BCD calculations - the C64's IRQ routine at $ea31 can't handle the situation if an IRQ occurs while decimal mode is on. This is a known Kernal bug. I suppose I could hack around that but this was simpler.