By the picture above we can notice that the problem with the black area was solved, and now, the entire screen is filled, so we can print on any corner (640x480 @ 60Hz). The problem was the interrupt function, the time of calling and returning was taking so much time for an ATmega328, I replace the functio call for an "if", checking the timer register all the time. When the timer gets a defined value (31.3KHz), the "if condition" is true and the line is printed. This way the program is not wasting time calling and coming back from the interrupt function.
Another problem was that only CRT monitors were understanding my signal. The problem was the voltage level, now I am using a resistor in series with a diode for R, B and G, forcing my TTL (5V) signal to become 0.7V, as VGA standards says, and any VGA monitor (including LCD and LEDs) can print the signal.
So, everything is solved now, and we can generate color VGA sinal.
Now, I will try to create a library intelligent enough to design shapes and letters, and maybe generate more colors.
Everything using just an Arduino UNO. :))
Here is the code I wrote. Enjoy! We are here to share.
If you are going to try this, you must know this too:
"VGA industry standard" 640x480 pixel mode
Clock frequency 25.175 MHz
Line frequency 31469 Hz
Field frequency 59.94 Hz
8 pixels front porch
96 pixels horizontal sync
40 pixels back porch
8 pixels left border
640 pixels video
8 pixels right border
800 pixels total per line
2 lines front porch
2 lines vertical sync
25 lines back porch
8 lines top border
480 lines video
8 lines bottom border
525 lines total per field
Be aware of turning your RGB signal off when sync pulsing.
And open your eyes for what the compiler is doing (or trying to do) when reading your code. A lot of time is wasted in many situations, and the non-repetitive ones are the most dangerous.
If your signal is not in perfect sync, the monitor will reject your signal.
Use the osciloscope to monitor all this things.
Good luck and count on me if you need help!