Shop OBEX P1 Docs P2 Docs Learn Events
Understanding the video generator — Parallax Forums

Understanding the video generator

MervinMervin Posts: 8
edited 2012-08-28 12:23 in Propeller 1
Today I built this RRGGBBII DAC Circuit for my DIY Propeller board.

I've been reading through the Datasheet and looking at some examples but the operation of the video generator is still not very clear to me.

the RRGGBBII format ofcourse means that I want to use 8 bits of color information per pixel, to give a max of 256 different colors on screen
(The HSYNC and VSYNC will be driven by some other mechanism)

My immediate goal is to draw something on my VGA monitor with support for 256 colors, so I've started making a 'driver' cog

My Propeller runs on a 5Mhz Crystal with PLL16X = 80Mhz.

I'm having trouble with a several things:

- How do I calculate the value required PLLDIV for Counter A for a given resolution Width*Height*8bpp and refresh rate R (50hz or 60hz)
- How do I calculate the values required for the Pixel Clock and Frame clock
- What is this i'm reading about four color mode and two color mode and "2 bit pixels", and giving a pixel array for WAITVID in the datasheet?. does this mean I can't set pixels with a depth of 256 values? and I have to set 16 or 32 pixels at once???

Please give me some info about the required math or small code examples (only C, SPIN, or ASM please)

Comments

  • ericballericball Posts: 774
    edited 2012-08-21 17:51
    Mervin wrote: »
    - How do I calculate the value required PLLDIV for Counter A for a given resolution Width*Height*8bpp and refresh rate R (50hz or 60hz)
    - How do I calculate the values required for the Pixel Clock and Frame clock
    - What is this i'm reading about four color mode and two color mode and "2 bit pixels", and giving a pixel array for WAITVID in the datasheet?. does this mean I can't set pixels with a depth of 256 values? and I have to set 16 or 32 pixels at once???

    Please give me some info about the required math or small code examples (only C, SPIN, or ASM please)
    See http://propeller.wikispaces.com/Video+Generator for more info on the Video Generator.

    See App Note 1 http://www.parallaxsemiconductor.com/an001 for calculating the PLLDIV. You basically need to know the pixel frequency (aka dot clock) and then calculate FRQA and PLLDIV based on CLKFREQ.

    Pixel Clock & Frame Clock depends on what you are doing. For VGA you usually have Pixel Clock = 1 and Frame Clock = number of pixels per WAITVID (4, 16, or 32 usually during the active part of the screen, as required during sync).

    WAITVID accepts two parameters - a four entry palette of 8 bit "colors" (output values for VGA) and a pixel bitstring. Every Pixel Clock PLLA one or two bits are shifted out of the pixel register and used as a lookup to the palette register. If you want 8 bit pixels then you load the palette register with your colors and use %%0123 for the pixel register. However, this method has a maximum dot clock of 1/9th CLKFREQ. 8bpp is also HUB RAM hungry - and you only have 32K total.
  • jonesjones Posts: 281
    edited 2012-08-23 09:21
    Mervin, you might have a look at Andre LaMothe's Hydra manual. It's available for free download from the Parallax store, just go to the Hydra Game Development Kit listing and scroll down to Downloads and Resources. I found his descriptions of the video hardware a little clearer than those in the Parallax docs.
  • MervinMervin Posts: 8
    edited 2012-08-28 02:43
    Ok, i've read through the material and set my pixel clock to 1 and frame clock to 4 to allow 8bpp
    I still don't have a clue about how to calculate the required vga clock for a given resolution (aka.. at which interval to let the video generator push out a pixel)
  • potatoheadpotatohead Posts: 10,261
    edited 2012-08-28 08:58
    If I were you, I would take a look at Kye's 8bpp driver. It runs at 160 pixels horizontally. A pixel clock of one probably is too fast. Pixels are expressed in terms of PLLA, and you need to determine the time the scan line takes from the sweep frequencies given. From there, you can find out how many PLLA cycles are on that scan line. From there, you then decide the number of pixels you need, and do the math to get PLLA / pixel.

    It takes time to load up a waitvid, fetch new values and loop back to load up the next waitvid. Because there are only 4 pixels in an 8bpp frame, low PLLA values might not yield enough time for the Propeller to load the pixels properly, corrupting the display.

    I had a hard time locating just the driver post. http://obex.parallax.com/objects/695/ That object contains the driver. The sprite driver in my signature also does full color VGA, and you can see the very tight timing required to get it done at just 256 pixels / scan line, and that's with the lowest sweep frequency that will display on most modern monitors. (640x400 or so interlaced)

    Examine that video loop, and use the values in that driver to verify your timing calculations. Once you can calculate those values yourself, then you will be much more able to format pixels on scan lines.
  • RaymanRayman Posts: 14,826
    edited 2012-08-28 11:16
    like potatoehead said, Kye's driver is a great place to start for that. There have also been several threads in this forum about this...

    I'm not sure anybody has actually achieved stable sync output with 8 color bits and bit-banged Hsync and Vsync though...

    BTW: If you want to get knee deep in the stock VGA.spin driver, I've added a lot of comments to it here:
    http://forums.parallax.com/showthread.php?133914-VGA.spin-Explained
  • tonyp12tonyp12 Posts: 1,951
    edited 2012-08-28 12:23
    I bitbang H+V sync here:
    http://forums.parallax.com/showthread.php?134552-Barebone-VGA-driver

    I got to to be in sync with HUB reads, but getting it to be in sync with VGA PLL I have not tried.
    And I think general view on this is to still use VGA PLL for sync, but switch banks when you want it active.
Sign In or Register to comment.