EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: pyrohaz on February 16, 2015, 03:14:04 am

Title: Weird lines on VGA controller?
Post by: pyrohaz on February 16, 2015, 03:14:04 am
Hi all,

After successfully designing a basic VGA controller in VHDL, I decided to have a go using my STM32F0 discovery board. My timers are synchronized to a 40Mhz clock (the whole MCU is running at 40MHz to simplify timings) and my monitor is syncing fine with the VSync and HSync signals, the colours however are really weird. I've written a simple program to draw vertical coloured bars and while the coloured bars work, there also seem to be some horizontal bars along with the vertical bars which isn't what I was expecting at all. If I ground all three colour inputs, the output stays black though the monitor remains synced.

I'm using the timer onepulse modes to create the VSync and HSync pulses. The one pulse mode only works from timer update to the relative capture compare (as far as I know!) so I resolved the phase difference between the VSync and HSync timers by setting the initial conditions to make the timers start at different periods. My code is: http://pastebin.com/xCF7qrhn (http://pastebin.com/xCF7qrhn)

Could anyone fathom a guess to this weird colouring phenomenon?

Cheers!
Title: Re: Weird lines on VGA controller?
Post by: Richard Crowley on February 16, 2015, 03:24:39 am
It looks like you are sending only the odd (or even).
You photo appears to show that only every OTHER line has your color bars on it.
That looks like a clear sign of a field problem.
Title: Re: Weird lines on VGA controller?
Post by: pyrohaz on February 16, 2015, 03:40:43 am
It looks like you are sending only the odd (or even).
You photo appears to show that only every OTHER line has your color bars on it.
That looks like a clear sign of a field problem.

Hi Richard,

Thank you for your swift reply! I see what you mean with respect to the colour every other line (I hadn't noticed that!) Would you care to elaborate on what you mean with respect to a "field problem"?

Thanks,
Title: Re: Weird lines on VGA controller?
Post by: Richard Crowley on February 16, 2015, 04:53:36 am
I don't know how you are generating the video data, but you are creating only half of what you need.  NTSC and PAL send odd/even frames alternately. The "even" frame contains all the even-numbered lines, and the "odd" frame contains all the odd-number lines.  You are generating only ONE of those frames, and the other one is blank (black).
Title: Re: Weird lines on VGA controller?
Post by: bktemp on February 16, 2015, 06:16:32 am
VGA is ac coupled: You need to set all outputs to black at the end of each line.
Title: Re: Weird lines on VGA controller?
Post by: voja on February 16, 2015, 07:56:47 am
Check your timings, this is the result of bad horizontal sync locking. Either the horizontal sync is way too long, or the time between horizontal sync signals is longer than required, so the monitor misses one horizontal sync and waits for next one, displaying nothing in the meantime, resulting in black line. There is a good timing list for all VGA resolutions and vertical refresh frequences at http://tinyvga.com/vga-timing (http://tinyvga.com/vga-timing)
Title: Re: Weird lines on VGA controller?
Post by: pyrohaz on February 16, 2015, 02:29:46 pm
VGA is ac coupled: You need to set all outputs to black at the end of each line.

This seemed to be the problem! After scoping my colour channels and comparing them to my HSync signal, it turned out the colours were still high during the HSync pulse and that was causing the problem. After clearing up my code a little, the problem was solved!

Thank you all for the help.
Title: Re: Weird lines on VGA controller?
Post by: ryanmoore on February 16, 2015, 02:52:08 pm
I don't know how you are generating the video data, but you are creating only half of what you need.  NTSC and PAL send odd/even frames alternately. The "even" frame contains all the even-numbered lines, and the "odd" frame contains all the odd-number lines.  You are generating only ONE of those frames, and the other one is blank (black).

VGA doesn't use interlacing for any of the common display modes.
Title: Re: Weird lines on VGA controller?
Post by: Richard Crowley on February 16, 2015, 04:19:01 pm
VGA doesn't use interlacing for any of the common display modes.

Bzzzzt! I skipped right over that!  I shouldn't try responding in the middle of the night.