Weird lines on VGA controller? - Page 1
Forum section: electronics / projects

author: pyrohaz
author_rank: Regular Contributor
timestamp: February 16, 2015, 03:14:04 am
content: 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/xCF7qrhnCould anyone fathom a guess to this weird colouring phenomenon?Cheers!

author: Richard Crowley
author_rank: Super Contributor
timestamp: February 16, 2015, 03:24:39 am
content: 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.

author: pyrohaz
author_rank: Regular Contributor
timestamp: February 16, 2015, 03:40:43 am
content: Quote from: Richard Crowley on February 16, 2015, 03:24:39 amHi 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,

author: Richard Crowley
author_rank: Super Contributor
timestamp: February 16, 2015, 04:53:36 am
content: 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).

author: bktemp
author_rank: Super Contributor
timestamp: February 16, 2015, 06:16:32 am
content: VGA is ac coupled: You need to set all outputs to black at the end of each line.

author: voja
author_rank: Contributor
timestamp: February 16, 2015, 07:56:47 am
content: 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 athttp://tinyvga.com/vga-timing

author: pyrohaz
author_rank: Regular Contributor
timestamp: February 16, 2015, 02:29:46 pm
content: Quote from: bktemp on February 16, 2015, 06:16:32 amThis 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.

author: ryanmoore
author_rank: Contributor
timestamp: February 16, 2015, 02:52:08 pm
content: Quote from: Richard Crowley on February 16, 2015, 04:53:36 amVGA doesn't use interlacing for any of the common display modes.

author: Richard Crowley
author_rank: Super Contributor
timestamp: February 16, 2015, 04:19:01 pm
content: Quote from: ryanmoore on February 16, 2015, 02:52:08 pmBzzzzt! I skipped right over that! I shouldn't try responding in the middle of the night.