VGA controller using PIC18F45K20

Discussion in 'Embedded Systems and Microcontrollers' started by peter_morley, Dec 18, 2011.

  1. peter_morley

    Thread Starter Member

    Mar 12, 2011
    179
    0
    I am using a PIC18F45K20 with PLL clock multiplier to get a clock speed of 64Mhz which means i can execute instructions (4 cycles) at 16MHz. Right now I am toggling the R signal line for the vga at a frequency of 8MHz. Basically I have a screen with vertical red lines separated by black lines. The problem is I am noticing a jittering of the vertical pixel lines. The weirder part is that 1 out of every 3 vertical lines jitters a lot while the other two barely jitter. Could this be clock instability? I have had this problem for awhile and I am not sure how to fix it. My source code is too large to put on this post so if you need it I can try to show it to you another way. Thanks
     
  2. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Last edited: Dec 18, 2011
  3. MrChips

    Moderator

    Oct 2, 2009
    12,450
    3,370
    No. This is not clock instability. This is caused by variations in execution times. It is very important that the video signal be generated at exactly the same time with reference to the horizontal sync signal. Any variation will show up as jitter. I am currently working on a system that is capable of generating VGA, SVGA and XVGA.
     
  4. peter_morley

    Thread Starter Member

    Mar 12, 2011
    179
    0
    when i test the frequency of my h signal i get small variations but isnt that expected due to the v signal low interruptions?
     
  5. MrChips

    Moderator

    Oct 2, 2009
    12,450
    3,370
    From what I have read on AAC from various attempts to generate VGA people are writing code to do this. This is not an efficient way to do this and will result in jitter problems as you have encountered.
     
  6. peter_morley

    Thread Starter Member

    Mar 12, 2011
    179
    0
    Are you saying i shouldn't try to write code? haha
     
  7. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Are you using Interrupts for timing?
     
  8. peter_morley

    Thread Starter Member

    Mar 12, 2011
    179
    0
    i am not at this point in time but i have before. What do you recommend using?
     
  9. MrChips

    Moderator

    Oct 2, 2009
    12,450
    3,370
    Here is the first attempt at VGA from a micro. I do not use interrupts. This is all done in hardware on the MCU.

    [​IMG]
     
  10. peter_morley

    Thread Starter Member

    Mar 12, 2011
    179
    0
    I am also noticing my blank lines are wider than my red lines. Is this due to the voltage being lower than 1 volt?
     
  11. MrChips

    Moderator

    Oct 2, 2009
    12,450
    3,370
    Do you have a scope? You can measure the widths of the video pulses on the scope. I suspect that is because you are using code to generate your video signal and one part of the code is taking longer than the other part.
     
  12. MrChips

    Moderator

    Oct 2, 2009
    12,450
    3,370
    Actually, yes. Code is going to introduce jitter in your display. Secondly, you will have little time left to do anything else useful.
     
  13. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    What resolution are you trying to run?

    IIRC, 8Mhz could run a 640x480 display somewhat acceptably, but with basic patterns. With 8 times the speed, you should be able to at least generate the 640x480 resolution.
     
  14. peter_morley

    Thread Starter Member

    Mar 12, 2011
    179
    0
    yes accessing ram takes a bit longer but i have been able to display text. I am starting from scratch again and trying to start with a perfect template so I won't run into any problems when I am far into coding. This jittering is making me mad. One out of every three lines is jittering so there might be a problem with my vsync timing along with my hsync. Like there is an offset and some draws it will draw red and the next it will draw black in the same pixel location. Is that how jittering happens?
     
  15. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    There have been a couple of people here lately who've talked about generating a VGA signal with a processor. I'd never tell anyone that something "can't be done" but it always seems doubtful to me, at least if you want full resolution. Here's a page about VGA
    http://en.wikipedia.org/wiki/Video_Graphics_Array
    and they talk about a pixel rate of just over 25MHz. That means data for 3 colors (8 bits each, at maximum color resolution) grabbed from memory, and sent through a DAC ready to put on the line at that rate. I'd like to hear how any processor can do it. I could imagine it working with an external clock and counter, reading memory and sending the data out, with a processor supervising. The logic could be in an FPGA, for greater elegance. But sending it through a processor just seems like too much. Or maybe I just don't know what processors are capable of!
     
  16. peter_morley

    Thread Starter Member

    Mar 12, 2011
    179
    0
    Are you saying an fpga is much different from say a PIC processor? Another thing I have read about online is the clock jittering when using the PLL clock multiplier for the PIC18 series. I have been trying to get rid of this pixel jitter forever and i know my code is written properly but i am still getting annoying jitter.
     
  17. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    An FPGA is far different from a PIC.

    They are logic arrays with memory and peripherals, and run in the Ghz range. The downside is development with FPGA can run into thousands of dollars and a steep learning curve.
     
  18. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Yes. Sync jittering will happen if you use C code to try to generate the sync pulses. You need to use hard code and a PIC timer, and possibly a timer interrupt using hard code (ASM). Generating jitter-free pulses on a PIC is one of the usual places people stumble in PIC video projects.
     
Loading...