It's time to start working on something I've wanted for a while now, and that is: honest to goodness old school CRT video!
A while back I bought several of these Hitachi CRT controllers on eBay:
Attachment:
20220701_193855.jpg [ 3.71 MiB | Viewed 978 times ]
They are used pulls from working systems. The legs are a little grody, so I'll use a machine-pin IC socket even during breadboarding to avoid putting too much stress on them. These are pretty close copies of the Motorola MC6845 CRTC, with a few enhanced features. One of those enhanced features is that it can take up to a 3.7Mhz character clock, which means it's one of the few old-school CRTCs that can produce VGA timings - which I'm sure Chad will be excited to hear!
Unfortunately, the MPU interface only runs at 2Mhz, so I will have to clock Blue April down by a factor of 4 in order to use it. Fortunately, my clock / reset module has some handy jumpers that provide a /2 and a /4 system clock, so the first order of business is to get that set up.
Then, in the spirit of Ben Eater, throwing it on the RC Project Platform, and connecting up some pins just to see if we can get it to do *something!*
First up, GND (with suitable bypass cap) and VCC are pins 1 and 20, respectively. That's easy enough. Then pin 3 is for light pen support. I don't have a light pen and, at least for now, have no plans to ever get one, so pin 3 can be tied low. Next up on the list of low-hanging fruit, pins 2 and 22 are the standard Motorola signals RESB and R/WB, so they can connect directly to the bus. Pin 23 is named `E` (Enable), but it is in fact the system clock input. Just like the stock 6845, the design of this chip has in mind that E will be connected to the Phi1 inverted clock output from the CPU for interleaved bus access. However, the RC6502 doesn't put Phi1 on the bus, and, anyway, I'd prefer to use the much nicer Phi0 clock coming off of the clock module. Fortunately I have plenty of spare 74AHCT14s leftover from the keyboard circuit, so I'll run Phi0 through that to get a nice inverted clock.
For address decoding, the HD6845 has pin 24 (RS) and 25 (CSB). RS is supposed to be tied to A0; taking it high gives you access to whatever register is currently selected by the Address Register. Taking it low gives you access to the Address Register itself. This means programming the HD6845's internal registers is, conceptually, a two step process, involving two consecutive memory locations. Pins 26 through 33 are the data pins, intended to be connected directly to the system data bus. Since the Project Platform doesn't have a huge amount of space, but it does have a spare VIA, and since I'm just trying to get to know the HD6845 a little bit, I'm not going to mess with address decoding; instead, the data pins connect to Port B, and CSB and RS will go to Port A. This makes writing to the CRTC a little more involved, but since that mostly only happens at system initialization, and since this is only temporary, it's no big deal. That pretty much completes the installation of the CRTC. It has a lot of memory address and raster address pins for the character generator, but since I don't have one of those yet, I'm not going to worry about them for now. There are three pins of interest left, though. Pin 21 is `CLK.` This is actually the input for the character clock. Theoretically this would be generated from the dot clock in the character generator, or supplied by an oscillator, but for now I'm just going to tie it to the 2MHz inverted system clock. Finally, pins 39 and 40 are HSYNC and VSYNC, respectively. I will tie them to my oscilloscope.
Here's everything hooked up:
Attachment:
20220702_152042.jpg [ 3.45 MiB | Viewed 978 times ]
Getting it to do something is now simply a matter of programming some sane values into its 18 control registers. The HD6845 thinks of everything in terms of characters rather than dots or clocks, so setting up the registers with something approximately normal is not too tricky; I went with 100 characters per line, 80 characters visible, 26 lines per frame, 24 lines visible. There are a couple of extra registers that let you tweak exactly where the sync pulses fall within the blanking periods, which I'm sure will be useful for whenever I eventually actually hook it up to a CRT. For now, I just want to make sure the chip is working, and programmable through the VIA. So I fired it up, and after twiddling with with my oscilloscope and laboriously counting 80+ clock pulses, I did indeed find an HSYNC pulse right where it was supposed to be.
Now I have to go do some math...