SCM App, CTC Mode 2 Interrupt Demo v1.0

This App demonstrates how to generate a periodic mode 2 interrupt using a Z80 CTC.

The program configures a CTC to generate a mode 2 interrupt every 5 milliseconds. The interrupt routine increments a counter upon each interrupt, thus counting up in 5-millisecond increments.

The program then monitors the counter and outputs a ‘*’ character to the terminal each time it detects that the counter has incremented 200 times.

This is a simple program that does not need to account for such things as missing the counter reaching 200 due to it not looking within every 5 millisecond period. A general-purpose solution would need to be more robust.

CTC channel 1 is set to generate an interrupt every 5 ms from a 7.3728 MHz input clock. The prescaler is 256 and the timer reload value is 144. The interrupt frequency is therefore 7372800 / 256 / 144 = 200 Hz.

The interrupt vector table starts at 0x8200 and is used as follows:
0x8200-8201 Interrupt vector for CTC channel 0
0x8202-8203 Interrupt vector for CTC channel 1
0x8204-8205 Interrupt vector for CTC channel 2
0x8206-8207 Interrupt vector for CTC channel 3

Recommended for Z80 processors
Small Computer Monitor (SCM) v1.0 or later
Z80 processor
(code starts at 8000)
Version 1.0 (2022-01-30)
Source code
Version 1.0 (2022-01-30)

Below is an example of the terminal output when loading and running the App.

Small Computer Monitor - RC2014
*         <<< send hex file here >>>

Homebrew 8-bit retro computing