Monday, January 12, 2009
PIC VGA update
So the pic wouldn't work on any monitor but my own. My monitor must be especially leniant because i was doing all of the timing wrong. WRONG!!
After a looking at the problem long and hard I came to realize i had missed something very important about VGA. The horizontal sync pulse must happen every 38.1 micro seconds, even in between active draw time. Before this realization, I was only pulsing HS during the 480 lines of active video and forgetting it during the vertical sync period.
A good example of this can be seen in this photo from http://martin.hinner.info/vga/640x480_60.html
So to remedy this i had to implement all the timing with a TMR0 interrupt. So every 381 instructions, TMR0 fires an interrupt, I pull HS low for 3.8 micro seconds, draw lines when needed, and pulse VS at the right time. Now the timing is very consistent and works on every monitor I have tried.
Another nice thing about using interrupts is that my program logic does not have to worry about timing. The logic just waits for drawing to stop with a loop. Then does its thing. Then waits in another loop for drawing to start.
Now I have a working pong game. It needs work, but this is a lot of progress in a few days...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment