# Calculating the time for a CPU cycle

As a learning exercise, I'm writing an emulator for the 6809 CPU. I'd like to simulate the speed of the CPU. I know the Motorola 6809E runs at 0.895 MHz and 1.79 MHz on the Color Computer 3. How do I figure out how many milli/nano seconds a cycle takes, so know how long of a delay I need on my modern machine?

• Great first question! Usually you would check the specifications, but I'm not sure of the standardisation of the specs at the time most of these chips were released. Jun 20, 2016 at 21:24
• Thanks @wizzwizz4 Although the problem wasn't knowing the specifications (I already knew the speeds of the CPU), it was knowing how tie the speed in MHz to the speed in seconds, which then shows how long to delay between instructions. The answer was perfect in this respect. Jun 22, 2016 at 19:56
• It was, and I upvoted it! I'm glad you're still active; I thought we might've scared you off by deleting that answer. Jun 23, 2016 at 5:55

It's one divided by the clock. So for 0.895 MHz divide 1 by 895000 and the answer is 1.117318 micro seconds. for 1.79 Mhz it's 558.6592 nano seconds.

I suspect however that the clock will be some multiple of NTSC timing (or PAL for European computers).

Wikipedia gives NTSC timing as 3.579545Mhz which divided by four gives 0.89488625Mhz (i.e. nearly your 0.895) with a cycle time of 1.11746045 micro seconds.

Note that in practice the timing for all this will not be to anywhere near this sort of accuracy IQD data sheets show that ±10 to ±50ppm is typical.

(edit) According to the wikipedia page the CoCo uses a 14.31818 MHz crystal so divide down by either 8 or 16 before calculating.

• According to the contemporary service manuals from Tandy, the CoCo 1 and 2 used a 14.31818 MHz crystal for its master clock, while the CoCo 3 used a 28.63636 MHz crystal (for NTSC; PAL CoCo 3s used a 28.4750 MHz crystal resulting in slightly lower clocking of the CPU...and there was apparently a PAL CoCo 2, but I don't have its manual). Jun 25, 2016 at 4:05
• The difference between 894.88 and 895 is an error of about one part per ten thousand? Can you tell the difference between a car going at 60mph and 60.008mph? :-)
– user6464
Oct 12, 2018 at 12:26
• Given the crystal accuracy I would agree. However I was trying to show where the number comes from. Oct 12, 2018 at 17:57