smart idea - using an RTC chip on the Spectrum
ZXNet echo conference «real.speccy»
From Kirill Frolov → To All 11 February 2002
Sometimes in programs it is necessary to count time in increments of less than 1
second.
The RTC chip only counts in seconds. For some
reasons, frame interrupts (20ms period) are not enough (for example, a modem connected using a Kondratiev
scheme
operates with interruptions - frame interrupts are often lost). The
A and B
RTC registers can be programmed to receive periodic interrupts with a period of 31.25ms. Of course, the processor will not receive the interrupts themselves (on the spec, the RTC interrupt output of the chip is not connected anywhere).
But it is possible, during each hardware interrupt (NMI, INT from the modem...) to poll
the RTC status register and detect the fact of an interrupt request. If interruptions
are not prohibited anywhere in the program by
DI commands, then they (in the case of using a modem) occur at least
times every 20ms (NMI or INT). In short, every 20..40ms you can receive an impulse
to increase
the time counter by 31.25ms, regardless of the operation of the modem. The accuracy
of the counter depends
only on the accuracy of the RTC +/- 20ms.
* Originally in CODE.ZX
* Crossposted in REAL.SPECCY