• Please review our updated Terms and Rules here

Programming the MC6845

Thrashbarg

Experienced Member
Joined
Apr 7, 2005
Messages
168
Location
Adelaide
Hi,

I'm making an MC6845 video card for my 8080 computer and I'm having difficulty programming it. I've calculated the registers to what seem to be appropriate values but I'm getting some very odd frequencies on the HSync and VSync pins.

I'm certain that the chip is receiving the correct data. I wasn't disabling the video RAM at one stage but I am now. The wires all check out with my multimeter beeper and I've tried several chips from different manufacturers, with the same results.

The clock is derived from a TTL 14.31818MHz oscillator, and divided by 8 for each character then sent to the MC6845's CLK input. Each character has a period of 558.7nS.

Does anyone know the correct way to program the MC6845? The datasheet says to initialize it by sending the data for the 15 registers sequentially, starting at R0 and finishing at R15.

For example, I send 114 - 1 to R0 which determines the time for the horizontal sweep in characters. 114 x 558.7nS = 64.251uS which is pretty close to the PAL standard, but I'm getting 111.8kHz (8.945uS) on the HSync pin read from my multimeter.

Any comments or links to documentation will help.

Thanks.
 
I love Murphy's Law sometimes :)

As soon as I posted this I get it going. Seems the word I created to send a string of data to the 6845 was bad. It's working now.
 
Thrashbarg,

Here is a great reference on MC6845 programming which may help you in your project:

http://amazon.com/s/ref=nb_ss_gw/10...-keywords=gerry+kane+CRT+controllers+handbook

Its the "CRT Programmers Handbook" by Gerry Kane and is I think the only technical reference manual which covers the MC6845, SY6545, and a whole host of other CRTCs. I own it and read it often.

My next project on my Test Prototype homebuilt Z80 computer is to build a video card based on the SY6545 which is very similar to the MC6845 except that it allows "transparent" access via a port rather than using shared memory like the MC6845 designs usually do.

Please post information on your MC6845 project, I am very interested in the subject and would like to compare notes with you. I have some schematics for various CRTC projects.

Thanks!

Andrew Lynch
 
A better place to go for older, used books is AbeBooks. I have recently bought quite a few technical books through them and have been very happy with the service. A lot of the time you will find the books you want cheaper through them, plus (more importantly) the shipping will be a little cheaper, especially if you get more then one book.

Cheers,

80sFreak

P.S. I bought from Pro Quo Books, BetterWorld.com and Frugal Media. Frugal Media did not send one of the books ordered from them, but then they pretty much bent over backwards to make it right. So then I went and bought a bunch of other books from them and they all arrived promptly minus one. But that one had the cost + shipping refunded (with an email notice apologizing for the mistake) before I received the order.
 
My next project on my Test Prototype homebuilt Z80 computer is to build a video card based on the SY6545 which is very similar to the MC6845 except that it allows "transparent" access via a port rather than using shared memory like the MC6845 designs usually do.

Andrew Lynch


Hello Andrew

It is a great project you are doing and please keep us posted about the
development. One question I have is about "transparent access". Would you
kindly explain the technical features?

Thank you

ziloo
 
Sure, no problem! Glad to help!

The MC6845 is a CRT controller chip. It is common and was used in the IBM PC CGA and MGA video cards. It is controlled via registers (IO ports) for various settings like characters per line, scanlines per screen, etc. MC6845 designs also have shared memory which is multiplexed between itself and the CPU. Usually 16K but can be more or less. The CPU has to be able to access the MC6845's RAM to manipulate the video RAM contents (ie, put characters on the display).

The problem with using MC6845's with Z80 CPUs and CP/M is that the OS design assumes pretty much exclusive access to the CPU memory and any shared RAM comes at the expense of TPA. As a result there are not a lot of graphical CP/M machines based on MC6845. Those which do often have dedicate graphics processors and the main CPU communicates only indirectly with the MC6845 via high level primatives or other methods.

Having shared MC6845 and CPU memory is the most difficult part of video card design for Z80 with CP/M. In addition, the MC6845 and CPU cannot access the video RAM during active video display or it will result in "snow" artifacts. It can be worked around but can be difficult but there are many ways to do it like bank switching, blanking interval access, memory interleaving, etc.

The SY6545 solves this problem by eliminating the shared memory and introducing "transparent" modes where the SY6545 has exclusive access to the video RAM, which is separate from the CPU main memory, and provides both control AND video RAM access via its IO ports. For Z80 CP/M systems this is much better since it eliminates the reduction of TPA memory space. The TMS9918 has a similar "transparent" mode where its control and video RAM is accessed solely by its registers (IO ports).

I am probably not giving all the important details on the MC6845 vs SY6545 considerations but those are the high points. It is all covered in the Gerry Kane book. I am planning on building a video card for my Test Prototype (Z80 CP/M) using an SY6545 design found in the Synertek application notes I found some time ago. I can provide that circuit if anyone is interested. Obviously, I am not done with it yet and am very interested in how Thrashbarg is proceding with his MC6845 design.

As soon as I finish the FDC circuit for Test Prototype, I am going to start on the video circuit. I have all the parts already and the design it just takes time to get it implemented. My last circuit (the IDE HD interface) took roughly a month to get all the hardware done, CBIOS written, and the kinks worked out. It will probably take the same for the FDC circuit so I won't be starting the video circuit for a few weeks yet.

Best of luck. If there are any questions, feel free to ask. I am sure there are lots of people on this forum with experience in this area.

Thanks!

Andrew Lynch
 
The SY6545 solves this problem by eliminating the shared memory and introducing "transparent" modes where the SY6545 has exclusive access to the video RAM, which is separate from the CPU main memory, and provides both control AND video RAM access via its IO ports.

I did this in TTL with my original graphics card which was based on the MC6847. I used three 74LS161 loadable counters (12 bits) which could be loaded with two ports and a third data port which would program the video RAM at the address pointed to by the counters. This would also automatically increase the counter's address.

It worked very well, minus snow, until the MC6847 packed it in. :(

I got colour working too which was quite a feat because the MC6845 is an NTSC device but I'm in Australia and all of the televisions are PAL. There was an add on board I got from the dead Dick Smith VZ-200 which I removed the MC6847 from. This converted the outputs of the MC6847 to a composite output which would work on PAL televisions. The only problem was the black was a dark red

I've got some pictures of the card working on my monitor here

http://kaput.homeunix.org/~thrashbarg/video/video1.jpg
http://kaput.homeunix.org/~thrashbarg/video/video2.jpg
http://kaput.homeunix.org/~thrashbarg/video/video3.jpg
http://kaput.homeunix.org/~thrashbarg/video/video4.jpg
http://kaput.homeunix.org/~thrashbarg/video/video5.jpg

I got my music program to display information about the channels on the screen too, including the volume of the three channels in different colours. I didn't get a photo or video of this though. There was significant snow at the top of the screen because the 8080 would wait for a video frame interrupt to update the screen, but it was slow enough for it to not be able to update the whole screen until the middle of the next frame. It was still an improvement on having the whole screen covered in snow.

Also, here are the schematics I'm basing my MC6845 CRT board on
http://www.swtpc.com/mholley/DS68/DS68_2a.jpg
http://www.swtpc.com/mholley/DS68/DS68_3a.jpg

The video circuit itself is essentially the same but the control circuit and CPU interface is different for the 8080 signals. I'll be using bank switching to access the video RAM, which is a total of 8K text only, and a device driver in higher memory. The lower 32k is switched out in my bank switch design. This also controls the ROM.

Notice on the first schematic how there's a buffer between the video RAM and the character ROM which is latched by the character load signal. This significantly reduces snow. I'm using a 74LS374 for this.
 
I did this in TTL with my original graphics card which was based on the MC6847. I used three 74LS161 loadable counters (12 bits) which could be loaded with two ports and a third data port which would program the video RAM at the address pointed to by the counters. This would also automatically increase the counter's address.

Good way to access to the video RAM without the pain of shared RAM. Basically the SY6545 does something very similar this in "transparent" mode which you did it with latches.

It worked very well, minus snow, until the MC6847 packed it in. :(

I got colour working too which was quite a feat because the MC6845 is an NTSC device but I'm in Australia and all of the televisions are PAL. There was an add on board I got from the dead Dick Smith VZ-200 which I removed the MC6847 from. This converted the outputs of the MC6847 to a composite output which would work on PAL televisions. The only problem was the black was a dark red

I've got some pictures of the card working on my monitor here

http://kaput.homeunix.org/~thrashbarg/video/video1.jpg
http://kaput.homeunix.org/~thrashbarg/video/video2.jpg
http://kaput.homeunix.org/~thrashbarg/video/video3.jpg
http://kaput.homeunix.org/~thrashbarg/video/video4.jpg
http://kaput.homeunix.org/~thrashbarg/video/video5.jpg

I got my music program to display information about the channels on the screen too, including the volume of the three channels in different colours. I didn't get a photo or video of this though. There was significant snow at the top of the screen because the 8080 would wait for a video frame interrupt to update the screen, but it was slow enough for it to not be able to update the whole screen until the middle of the next frame. It was still an improvement on having the whole screen covered in snow.

I take it you connected the display enable signal to your 8080 interrupt line to detect blanking interval? I have read others recommend adding a signal delay to it for the very reason you mention. The MC6845 tends to say it is ready for blanking interval before it actually blanks the display.

Also, here are the schematics I'm basing my MC6845 CRT board on
http://www.swtpc.com/mholley/DS68/DS68_2a.jpg
http://www.swtpc.com/mholley/DS68/DS68_3a.jpg

The video circuit itself is essentially the same but the control circuit and CPU interface is different for the 8080 signals. I'll be using bank switching to access the video RAM, which is a total of 8K text only, and a device driver in higher memory. The lower 32k is switched out in my bank switch design. This also controls the ROM.

Notice on the first schematic how there's a buffer between the video RAM and the character ROM which is latched by the character load signal. This significantly reduces snow. I'm using a 74LS374 for this.

Excellent work Thrashbarg. Congratulations on your video card. Consider me envious already! Sorry to hear about your MC6847 -- those are getting hard to find. It would be tough to replace short of buying a COCO and ripping the part out.

OK, you are using the DS68 MC6845 design. I have seen it and think it is very well documented. The sample code is in 6800 but that is not much of a problem since you'd have to rewrite it anyway regardless of platform.

The issue I had with the design is it requires a 2 phase clock. The 8080 already uses a 2 phase clock though so that should not be a problem, right? The Z80 uses only a single phase clock which makes things a bit more complicated. I think you can simulate the phi2 signal by just inverting the main clock but it was enough for me to keep looking and then I found the SY6545 design. Still, the SY6545 design requires phi2 as well but I believe I can just simulate the input.

I would post a diagram of the SY6545 circuit but can't get it to attach to this message and I do not have a web page to post it on. If you'd like to see it I can just mail it to you. My plan is to further simplify it by using a 32K x 8 SRAM part and eliminating the multiple small SRAMs and related 74LS139 demultiplexer

Well best of luck and congratulations on your working video card. I am impressed and appreciate you sharing your design and experiences.

Thanks!

Andrew Lynch

PS FOR GREAT JUSTICE!
 
Last edited:
using LCD panels

using LCD panels

Hello folks,

1- In many homebuilt projects, one wants to use an LCD panel for video monitor.
Suppose you have designed a computer with H-sync, V-sync, and video signal
coming out for display. Which LCD panel should one use, and what interfacing
hardware is require to make it operational?

2- Do you have the data sheets for TMS9918 and SY6545...


Thank you

ziloo
 
Last edited:
Hello folks,

1- In many homebuilt projects, one wants to use an LCD panel for video monitor.
Suppose you have designed a computer with H-sync, V-sync, and video signal
coming out for display. Which LCD panel should one use, and what interfacing
hardware is require to make it operational?

Personally, I would design for CRT first and retrofit and LCD in later. I have found the older CRTC designs tend to favor composite video monitors. Some due support separate RGB signals but it usually involves modifying the design. I would do that later after the circuit is proven to work with a CRT.

2- Do you have the data sheets for TMS9918 and SY6545...

Yes, but in both cases you need application notes above and beyond the datasheets. That is especially true for the SY6545 since all it talks about is MC6845 compatibility and none of the special transparent modes.

I recall the TMS9918 is more detailed in its data sheet.

I have all of those materials and they are all available on the internet. I have additional SY6545 material over that plus you probably want the Gerry Kane book "CRT Controllers Handbook" to supplement. I can send you the SY6545 material if you want it.

Thank you

ziloo

Best of luck! Thanks!

Andrew Lynch
 
In many homebuilt projects, one wants to use an LCD panel for video monitor.

Not me, too expensive :)

ziloo said:
Suppose you have designed a computer with H-sync, V-sync, and video signal coming out for display. Which LCD panel should one use, and what interfacing hardware is require to make it operational?

Best bet is a nice and expensive VGA LCD monitor, they have the required H and V sync signals. Also there are parallel and serial LCD modules which are either alphanumeric or graphical but I find them to be too small and too low in resolution, unless you want to spend about $100 or more. These don't require a video interface, just a connection to the CPU of some sort.
 
Hello Thrashbarg

I am new here in this world. I saw your post about programming MC6845. The dates of this forum look really old and I am not if sure you guys are still using this.
I have got one project to solve and there is not much information online. After doing some research I found a datasheet and this forum. I have got an old video card that uses MC6845 and produces 16.34KHz Horizontal Sync and 50Hz Vertical Sync frequencies. I wanted to change the register values so that it can produce 60Hz vertical sync and either 15.6KHz (?) for a standard TV or 25.5KHz(?) for an LCD monitor. The video card is using 16.667MHz oscillator clock. There is worksheet in the datasheet or specification document but that is not 100% clear to me. I understood Horizontal calculation but I think there is something goofy about vertical sync calculation. There is an example done but that doesn't make sense with the worksheet instruction. I couldn't find any application note or anything to do the math proper way. So I am confused. I saw you set 113 to R0. Could you please provide me other register value and calculation details so that I can do it for 16.667MHz oscillator? I also have option to use other oscillator frequencies such as 16MHz, 20MHz or 25.175MHz.

Did you use a TV or an LCD monitor for your display project?

I was planning to set all the registers by using an ATMEL microcontroller as I am not going to produce or change any graphical information. I just want to change the frequencies so that newer standard TV or LCD monitor can be used for display instead of the old ancient small CRT monitor. I might need more help on programming the registers once I figure out the values for them.

Thanks in advance
Hasib
 
Back
Top