Jiffy Clock

From C64-Wiki
Jump to: navigation, search

The Jiffy Clock is a free-running hardware clock used as a hardware interval timer. The Jiffy Clock value is set to zero (initialized) when the system is powered-up.

Jiffy as a time interval[edit]

In computing, a jiffy was originally the time between two ticks of the system timer interrupt[1]. Whereas in electronics, a jiffy is the time between alternating current power cycles in most mains power supplies[2]. Specifically in the C64 the Jiffy Clock works on an outside frequency input and it is unsurprising to find that it is pegged to the vertical refresh period of the national television standard. In countries using the NTSC standard this is 59.94 Hz (16.8 ms) while in countries using the PAL standard this is 50.0 Hz (20.0 ms). By contrast, in more modern computers a jiffy is standardised at 10 ms.

Accuracy[edit]

A jiffy in the C64 is therefore not an absolute unit of time. Although the frequencies of the national television standards are very accurate, the clock interrupt frequency is turned off during tape I/O. This notwithstanding, if the clock interrupt frequency was not turned off (for example when using the C64 as a server) then it is still inaccurate. The reason is that the C64 ISR does not use ADC, but instead uses SBC each jiffy when the jiffy clock is updated (TI$ and TI)[3]. After the clock is incremented, the number $4F1A01 (or 5184001 jiffies, which is 24 hours + 1 jiffy) is therefore subtracted from the 24-bit count. If carry is set, the count is set to zero. The consequence of the subtraction is that there is the loss of 1 jiffy (16.8 ms or 20.0 ms) each day.

References[edit]

  1. Reducing Scheduling-Clock Ticks], accessed 24 September 2014
  2. What’s a Jiffy?, accessed 24 September 2014
  3. BCD math on 6502 (ADC/SBC algorithms)? accessed 24 September 2014