A project log for VGA Graphics Over SPI and Serial - VGATonic

640x480 (and 848x480!) Color VGA Video Card for Microcontrollers and Single Board Computers

PKPK 09/16/2015 at 06:340 Comments

I'm happy to show a major milestone tonight; I got NTSC working on VGATonic's rev A board!

Call it NTSCTonic!

Here are the vitals:

  1. 320x240 'Fake' Progressive scan (as in not interlaced)
  2. 4 Bit Color
    1. (There are a lot more available for a future 256 color mode; I'll explain below)
  3. 21.977 MHz estimated top SPI Speed (so, 71 frames per second - capped at 60)
    1. Equation derived here, with a user clock of (17,896,845.40452/2) Hz

Getting NTSC To Work

It's in a messy state right now so I won't post the firmware that made it happen (watch for it soon!), but here's the rough sequence I took to getting NTSC working on VGATonic:

  1. Find a clock setting on the Linear LTC6903 which is a multiple of the NTSC colorburst frequency of 3.57954 MHz - OCT 14 DAC 100 gives us 17,896,845.40452 Hz, or a .005% error for 5x the NTSC clock
  2. Figure out which shades of colors I had. 360 degrees divided by 5 means 5 phases/colors, but since it is an odd number I can also INVERT those phases (shift them by 180) for 5 free phases. That leaves us with this:
    Phase Degrees from Colorburst 0 36 72 108 144 180 216 252 288 324
    Color Name Yellow Light Green Green Cyan Indigo Blue Purple Magenta Red Orange
  3. If you look at the schematic for the rev A board (linked nearby) you'll note I also have a number of outputs for "Luma", which controls brightness. For this firmware release, I wanted to easily match one of the VGA modes, and 16 color/4 bit allowed me to do that with limited colors and luma.
    1. A motivated builder could get up to 10 shades + Black/White Gray (11) and 16 shades of luma, or 176 colors by just changing the mapping. For more colors, you'll need a higher frequency for more phases.
    2. Also, note that the colors won't match VGA perfectly, so you'll have to come up with translations (these 16 are hard coded in VHDL and it fits easily in the CPLD).
  4. In practice, my colorburst frequency was .07% off - it works on my monitors, but seriously... if you do an NTSC project, use an oscillator with a magic frequency multiple of 3.57954 MHz instead of trying to do it like this!

I will post some code soon if you want to build it, then I will work on adding a higher resolution VGA option on the rev B board!