Arduino VGA via Interrupts

Basic VGA Theory
           The theory of VGA relies upon being able to successfully display the color data, then horizontal synchronize and vertical synchronize, all at specific times that cannot be missed.
           The Arduino UNO runs off of a 16 MHz crystal oscillator and since it runs 1 clock cycle per instruction that means that each executed assembly instruction of our program will take exactly (1 / 16,000,000) of a second or about 62.5 nanoseconds.



Using Interrupts
           Since the most common synchronization pulse is the horizontal sync, we'll set up a timer interrupt to trigger interrupt every 3.2uS. This means we'll use the interrupt itsself to display all video data and handle Vsync then return to the main loop and 3.2uS later, the interrupt will trigger again repeat outputting the line data.



           Since the timer interrupt will be set to interrupt every 3.2uS that means the main loop will only have time to execute about 48 assembly instructions. Since we're programming entirely in C, that doesn't give us a lot of time to do much in the main loop. However, it is just enough time to set what color should be output on the screen, so we should still be able to reach our stated goal.