VGA controller using PIC18F45K20

Thread Starter

peter_morley

Joined Mar 12, 2011
179
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
 

MrChips

Joined Oct 2, 2009
30,714
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.
 

Thread Starter

peter_morley

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

MrChips

Joined Oct 2, 2009
30,714
when i test the frequency of my h signal i get small variations but isnt that expected due to the v signal low interruptions?
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.
 

MrChips

Joined Oct 2, 2009
30,714
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.
 

thatoneguy

Joined Feb 19, 2009
6,359
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.
 

Thread Starter

peter_morley

Joined Mar 12, 2011
179
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?
 

John P

Joined Oct 14, 2008
2,025
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!
 

Thread Starter

peter_morley

Joined Mar 12, 2011
179
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.
 

thatoneguy

Joined Feb 19, 2009
6,359
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.
 

THE_RB

Joined Feb 11, 2008
5,438
y...
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?
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.
 
Top