RGB output at 31KHz pixel clock freq

Hi all,

I would like to ask here a question that has been bothering me a lil bit in the last week.

I am working on manipulating some RGB VGA signal via Arduino (Mega 2560).

So far so good, but the problem comes when I want to output the COLOUR to the monitor (h and v sync are good).

The problem basically is that I need to use analogWrite to be able to generated the 0.7 p2p colour signals, but this takes some time and I do not get the colour information into the monitor properly.

I was wondering if I am even doing things write by using the analogWrite function on the 3 pins that output the colour to the monitor...

I read that the freq output of the PWM pins is at the most 980 Hz, which is far from the 31 KHz I need to cope with the VGA 640x480 @75 Hz specs....

How can I achieve such a quick output of that signal? Might the DUE solve my problems? I couldn't find specs regarding DUE's PWM freq....

Note: Is it possible to use the PWM output pins by using the chipset isntructions ( i.e. PORTH, PORTD...)?

Thank you!!

The Arduino AnalogWrite() function produces a PWM on a single pin. i.e. you get a variable duty PWM signal that can only be refreshed during a PWM period. (and you probably need to go through a low-pass filter to get a "smooth" analog voltage)

If you want to produce a fast Analog voltage, you either use a chip with hardware DAC or you connect your own resistor network to a PORT for each colour. e.g. 3 8-bit PORTs instead of 3 individual pins.

In practice, you can get away with 4-bit colour. Look at how atomiczombie does things. Or any AVR VGA project.


hi David,

thx, actually those projects cover exactly what I was looking for, but they are directly in ASM over the AVR so... far beyond my current knowledge :( I will try to infer the missing piece i have in my current arduino project, so far i see that i will need a DAC.. but when i bring the extra ram (DRAM, ideally) maybe directly loading in the original digital values from the vga signal and outputting them to the new vga signal will remove all this complexity....