I'm hoping someone can clear up some confusion for me. I've been hammering away at my AVR (ATMEGA328 @ 16Mhz) for a few days now in a vain attempt to achieve video output with it (just greyscale). I've researched the topic thoroughly, reading almost any article I can find on the subject, including the ubiquituous articles of Rickard Gunee and the fairly comprehensive notes at Batsocks (home of Tellymate).
I believe my lack of progress is related to my lack of understanding of a few fundamentals.
Firstly, I had believed that I could get some sort of image on the screen (e.g full white or full black) just by sending accurate h-sync pulses followed by an output at white or black level. Is this correct, or do I need to account for anything else? For example, considering the ~12uS blanking period; how much of this do I need to account for? Should you always set the front/back porch at the beginning/end of each line regardless? Are these pulses always at black level? I understand the difference between "blanking" and syncing, but am confused as to how they both relate to your average scanline.
I've written a very simple program in assembly that has a timer interrupt that fires at the beginning of each scanline (~64uS), the timer ISR simply sends a sync pulse (4uS), followed by an 8uS backporch (don't really know what I'm doing here, just making up the total 12uS "pre-picture" part of each line). Then, during the main program loop, I just output at white level until interrupted again and so on.
I'd have expected to see a plain white screen by doing this, but instead I have two grey bars (picture attached) that jitter slightly. The bars actually seem to be my sync/backporch pulses (the second is almost exactly twice the width of the first), which I'd have expected to be off-screen. Also, as it may not come out perfectly in the image, the rest of the screen (allegedly at white level) is a pale grey.
In terms of hardware, I just have a 1K and 470 ohm resistor connected up to the TV and to sync/video pins on the AVR respectively (the setup is identical to the Arduino TV-out schematic). In case I'm making a mistake here, I'm just setting both to low for sync, the 1K path to high for black level and both high for white level. No matter what I do, I can only get shades of grey on the screen.
It's obvious I'm doing something seriously wrong, but the more I read on the subject, the further it seems I'm getting from actually seeing it work. Obviously something is working right, as my TV actually sees the pulses as a video signal, albeit a messed-up one (my early attempts were merely a case of the endless "No Signal" message).
If possible, would someone please be kind enough to outline the exact procedure I need to follow to get a minimal display working. By minimal I mean something along the lines of:
- No need for v-sync initially
- Just the ability to draw white/black horizontal bars
- Is acceptably jitter-free
I'm not asking for a complete code example or anything, just the steps that need to be taken, especially accounting for the blatant gaps in my knowledge.
Hopefully this post makes some sense.
Thanks in advance.