Shop OBEX P1 Docs P2 Docs Learn Events
How to make a 1280x1024 black and white grid on VGA port using Propeller — Parallax Forums

How to make a 1280x1024 black and white grid on VGA port using Propeller

mtomarmtomar Posts: 6
edited 2014-08-20 15:12 in General Discussion
Hi,

I am trying to get a 1280x1024 black and white grid using the VGA port on Propeller. the demo code uses a driver where we save the complete image data as display buffer which doesn't work for higher resolutions. Any suggestions how to go about it.Thanks!!

Comments

  • localrogerlocalroger Posts: 3,451
    edited 2014-07-28 18:39
    If you just want a repeating grid pattern you can use a tile driver -- the VGA_Hirez drivers will do that resolution and they use their own character set which you can change as necessary to create grid building blocks.
  • mtomarmtomar Posts: 6
    edited 2014-07-29 11:41
    Below is the code I am writing to create a VGA signal,as I believe we only need these five signals. But am not sure if I need to set any other parameter as well to make it work. As of now nothing appears on screen.

    #define printf __simple_printf
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include "propeller.h"
    #include "simpletools.h"


    int RedPin1=22;
    int RedPin2=23;
    int GreenPin1=20;
    int GreenPin2=21;
    int BluePin1=18;
    int BluePin2=19;


    int VsyncPin=16;
    int HsyncPin=17;


    int hResolution = 640;
    int vResolution = 480;


    void setBlack(){

    low(RedPin1);
    low(RedPin2);
    low(GreenPin1);
    low(GreenPin2);
    low(BluePin1);
    low(BluePin2);

    }


    void setWhite(){

    high(RedPin1);
    high(RedPin2);
    high(GreenPin1);
    high(GreenPin2);
    high(BluePin1);
    high(BluePin2);



    }


    int main(){
    int n;
    n=10000;
    unsigned int clkfreq = _CLKFREQ;

    long int HfrontPorch = (clkfreq / 1000000) *0.94* n;
    long int HbackPorch = (clkfreq / 1000000) * 1.89*n;
    long int HsyncPulse = (clkfreq / 1000000) * 3.77*n;
    long int HactiveVideo = (clkfreq / 1000000) * 25.17*n;

    long int VfrontPorch = (clkfreq / 1000) * 0.35*n;
    long int VbackPorch = (clkfreq / 1000) * 1.02*n;
    long int VsyncPulse = (clkfreq / 1000) * 0.06*n;
    long int VactiveVideo = (clkfreq / 1000) * 15.25*n;

    low(VsyncPin);
    low(HsyncPin);
    setBlack();
    while(1){


    waitcnt(_CNT + VfrontPorch);


    high(VsyncPin);
    waitcnt(_CNT + VsyncPulse);


    low(VsyncPin);
    waitcnt(_CNT + VbackPorch);
    for (int i =0; i < 480; i++) {

    waitcnt(_CNT + HfrontPorch);
    high(HsyncPin);
    waitcnt(_CNT + HsyncPulse);

    low(HsyncPin);

    waitcnt(_CNT + HbackPorch);
    setWhite();
    waitcnt(_CNT+ HactiveVideo);
    setBlack();
    }
    }
    }
  • Bill HenningBill Henning Posts: 6,445
    edited 2014-07-29 15:29
    you cannot write a 1280x1024 driver in C, or even generate that signal from C.

    Read up on the video hardware, and write it in assembly code.

    FYI, there is not enough memory to do a bitmap, but like Roger says, you could display a grid made from tiles.
  • mtomarmtomar Posts: 6
    edited 2014-07-29 16:15
    Thank you for the information. But as am completely new to microprocessor world. Could you please guide me where to read about the Video Hardware from? And does using a tile driver means its a code which produces a tile on VGA and I run it in a loop for painting a complete screen with patterns that I want to generate? Also, I could not find the tile driver..:/
  • Bill HenningBill Henning Posts: 6,445
    edited 2014-07-29 16:31
    Happy to help.

    Propeller manual, has information in video circuitry and instructions:

    http://www.parallax.com/sites/default/files/downloads/P8X32A-Web-PropellerManual-v1.2_0.pdf

    Hydra manual - has really good explanation of video generation:

    http://www.parallax.com/sites/default/files/downloads/32360-Hydra-Game-Dev-Manual-v1.0.1.pdf

    The following object from Obex would be a good basis for what you want, you just need to make a C wrapper to replace the Spin wrapper.

    VGA 1280x1024 Tile Driver w/Cursor
    This object generates a 1280x1024 VGA display from a 80x64 array of 16x16-pixel 4-color tiles.
    It requires three cogs (or four with optional cursor enabled) and at least 80 MHz.

    http://obex.parallax.com/object/646
    mtomar wrote: »
    Thank you for the information. But as am completely new to microprocessor world. Could you please guide me where to read about the Video Hardware from? And does using a tile driver means its a code which produces a tile on VGA and I run it in a loop for painting a complete screen with patterns that I want to generate? Also, I could not find the tile driver..:/
  • mtomarmtomar Posts: 6
    edited 2014-07-29 16:35
    Thanks!! let me look into these links and I might bug you more if I don't understand anything. :)
  • Bill HenningBill Henning Posts: 6,445
    edited 2014-07-29 16:37
    You are welcome :)
    mtomar wrote: »
    Thanks!! let me look into these links and I might bug you more if I don't understand anything. :)
  • PropGuy2PropGuy2 Posts: 360
    edited 2014-07-30 14:43
    I have had excellent results for using Kuroneko's single cog VGA demos & drivers. They are found elsewhere in the general Discussion & Propeller 1 forums. There are several good VGA demos available - easy to use single cog VGA driver with standard ROM font, custom character font and a full palette of foreground and background colors. I am using a 40x15 driver - 40 columns by 15 lines, with excellent results. The following is the title block you will be looking for, published in 2013
    ''VGA display 40x15 (single cog, ROM font, palette) - demo
    '' Author: Marko Lukat
    '' Last modified: 2013/10/25
    '' Version: 0.2.pal.7
  • localrogerlocalroger Posts: 3,451
    edited 2014-07-30 16:38
    In addition to what Bill said, even in assembly you won't be able to display a very good VGA signal with simple bit-banging because the instruction timing is too coarse; this is why WAITVID and the PLL's exist. This hardware allows you to set very finely grained clock frequencies and shovel data out with precise timing based on those clocks. There's a lot to understand in order to write your own video driver, and some of it isn't very well documented anywhere.

    VGA monitors tend to be very picky about their timing, and most will refuse to sync to a signal that isn't fairly accurate.

    However there are lots of objects and projects out there where people (including myself) have done different combinations of functionality. While it's hard to write a video driver it's much easier to take a tile driver someone else has written and write font maps for it.

    (We call them tile drivers because the "tiles" represent a combination of bitmap and color information; they usually involve some creative shifting to load properly as the tile format is optimized for shoveling bits out to the video hardware, and some drivers can have more than 256 tiles so they're not really "characters.")

    If you have enough tiles you can devote a group of them to making a bitmap canvas, and if your resolution is low enough (the limit is 32K of Hub RAM for bit data) you can actually have a full screen bitmap.
  • mtomarmtomar Posts: 6
    edited 2014-08-15 10:44
    hi again,

    So this is what I have been trying. Can anyone explain me how to get the values of the following parameters for various resolutions in the format given below if I know the timing descriptions for various resolutions.

    static const uint32_t invisibleScale = (16 << 12) + 160;
    static const uint32_t visibleScale = (4<<12) + 16;
    static const uint32_t blankPixels = 640;
    static const uint32_t syncPixels = 0x3FFC;
    static const uint32_t HSyncColors = 0x01030103;
    static const uint32_t VSyncColors = 0x00020002;
    static const uint32_t HVSyncColors = 0x03030303;

    I know the values for a VGA signal in the format below instead :



    ParameterValueUnit

    Pixel clock frequency
    25.175
    MHz[10]


    Horizontal frequency
    31.469
    kHz


    Horizontal pixels
    640



    Horizontal sync polarity
    Negative



    Total time for each line
    31.778
    µs


    Front porch (A)
    0.636
    µs


    Sync pulse length (B)
    3.813
    µs


    Back porch (C)
    1.907
    µs


    Active video (D)
    25.422
    µs





    ParameterValueUnit

    Vertical lines
    480



    Vertical sync polarity
    Negative



    Vertical frequency
    59.94
    Hz


    Total time for each frame
    16.683
    ms


    Front porch (A)
    0.318
    ms


    Sync pulse length (B)
    0.064
    ms


    Back porch (C)
    1.048
    ms


    Active video (D)
    15.253
    ms





    If someone can help me to understand how above values have been derived from the table below, It will help me assign values for 1280x1024 as I know the timings for this resolution but don't know How to convert.

    I am using these values for the code below:

    https://code.google.com/p/propside/source/browse/propside-demos/C-VGA/vga.cogc?r=76b72d90083f6cc3cd2af52b4d20b6e062bb33fb.

    Please help me make necessary changes in the parameters above for a new resolution.
  • mtomarmtomar Posts: 6
    edited 2014-08-20 15:12
    HI Can anyone please guide me into what all parameters to change in this driver for making it work at a new resolution say 800x600. I need it urgent. Thank you.

    https://code.google.com/p/propside/source/browse/propside-demos/C-VGA/vga.cogc?name=beta_v0_7_2&r=1a0bd3f7931eb25df5fe5844cdcdfc6d853918fe
Sign In or Register to comment.