Day 6: RC2014

Changing domains for a bit, and getting back into my Z80 based RC2014 computer to learn how to manipulate the the timer.  The timer is a separate chip, a Z80 CTC, and the board is designed by Dr. Scott Baker.  I’m also going to steal some inspiration from Leonardo Miliani, who’s recently done some similar work on the CTC.  This video is also a good reference.

The CTC has 4 channels, each of which can operate as a counter or a timer.  It’s run off an external clock, has a built in prescaler of /16 or /256, and can be set to send interrupts.  Channels can be cascaded when longer times are needed.

Each of the 4 channels takes one or two control words (bytes), and in the case of sending a time constant, we have to send those 2 words consecutively.  This basic program sends the 1st control word which sets up the parameters of the channel, and the second word sends the time constant.  In the Timer mode, which is the mode we’re interested in, the time constant is the divisor.  The period of the Timer output is the Clock * the Prescaler * the Time Constant.

20 REM 30 REM COUNTER ATTEMPT USING SMBAKER BOARD AT 0x40 40 REM VARIABLES 50 REM 60 REM AD0 IS THE ADDRESS OF THE BOARD 70 AD0 = &H40 80 REM 90 REM CT00 IS THE CONTROL WORD 100 CT00 = 0 + 0 + 0 + 16 + 0 + 4 + 0 + 1 110 REM 120 REM CT01 IS THE TIME CONSTANT 130 GOSUB 1000 140 REM 150 REM OUTPUT CONTORL WORD, FOLLOWED BY TIME CONSTANT 160 OUT &H40,CT00 170 OUT &H40,CT01 180 GOTO 130 190 REM 200 REM 1000 REM SUB: GET INPUT 1010 KIN = INP(&H81) 1030 IF KIN = 32 THEN PRINT "ENTER TIME CONSTANT":INPUT CT01 1040 OUT 0,CT01 1050 RETURN
Code language: PHP (php)

The program will prompt for the time constant when the spacebar is pressed, and show the selected time constant in binary on the LEDs at port0.

Note that the pulses are super short, and of a fixed width. If you’re trying to do something slower with them, they may need to get stretched into something useful. At lower repetition rates, they aren’t really visible on a scope as a train of pulses.

This entry was posted in Blinking Lights. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *