VGA display library for Arduino and RP2* microcontrollers
This is an Arduino library providing a VGA display-driver for the RP2* family of microcontrollers. The goal of this library is to provide an easy way to drive a relatively low-res vga screen directly from the Arduino framework, and not having to install compilers or the pico development environment.
It can drive up to 2 screens simultaneously on an RP2040 microcontroller, and 3 screens on RP2350 microcontrollers (this latter one is under development).
RP2350 GPIO pin | connected | VGA connector pin | |
---|---|---|---|
GPIO 16 | 330R | -> | 1 - Red |
GPIO 17 | 330R | -> | 2 - Green |
GPIO 18 | 330R | -> | 3 - Blue |
GPIO 19 | 3x470R | -^^^ | 1,2,3 pins |
GPIO 20 | -> | x - Vertical sync | |
GPIO 21 | -> | x - Horizontal sync | |
GND | -> | 15 GND |
For this library to work, the CPU frequency has to be selected manually in the Arduino IDE to match the resolution used in the code. The CPU frequency must be an integer multiple of the pixel frequencies below. See "Pixel freq" and "CPU freq" column. (note: for 25.175Mhz pixel frequency, the round 25MHz cpu frequency is apparently good enough)
Resolution | Refresh rate | Pixel freq | CPU freq | Divider | Dev status |
---|---|---|---|---|---|
640x480 | 60Hz | 25.175 MHz | 100 MHz | 4x | working |
640x480 | 60Hz | 25.175 MHz | 125 MHz | 5x | working |
640x480 | 60Hz | 25.175 MHz | 150 MHz | 6x | working |
640x480 | 60Hz | 25.175 MHz | 175 MHz | 7x | testing |
640x480 | 60Hz | 25.175 MHz | 200 MHz | 8x | working |
640x480 | 60Hz | 25.175 MHz | 225 MHz | 9x | testing |
640x480 | 60Hz | 25.175 MHz | 250 MHz | 10x | testing |
800x600 | 60Hz | 40.000 MHz | 120 MHz | 3x | working |
800x600 | 60Hz | 40.000 MHz | 200 MHz | 5x | working |
800x600 | 85Hz | 56.250 MHz | 225 MHz | 4x | devel |
800x600 | 60Hz | 40.000 MHz | 240 MHz | 6x | working |
1024x768 | 70Hz | 75.000 MHz | 225 MHz | 3x | testing |
The table below shows sync polarity, front porch, sync pulse and back porch lengths for both horizontal and vertical sync lines.
Resolution | Refresh | Horizontal | Vertical | ||||||
---|---|---|---|---|---|---|---|---|---|
polarity | front | sync | back | polarity | front | sync | back | ||
640x480 | 60Hz | --- | 16 | 96 | 48 | --- | 10 | 2 | 33 |
800x600 | 60Hz | +++ | 40 | 128 | 88 | +++ | 1 | 4 | 23 |
800x600 | 85Hz | +++ | 32 | 64 | 152 | +++ | 1 | 3 | 27 |
1024x768 | 70Hz | --- | 24 | 136 | 144 | --- | 3 | 6 | 29 |
For the 640x480 resolution a round 25MHz is used as the pixel clock, instead of 25.175MHz specified in the standard. For the 1024x768 resolution the vertical front porch of 2 rows is used instead of 3 rows, because of PIO state-machine space-constraints. All monitors tested seem to tolerate these so far.
- RGBargy licensed under MIT license
- The Arduino IDE and ArduinoCore-API by the Arduino team. IDE is licensed under GPL.
- The RP2040 GCC-based toolchain is licensed under the GPL.
- The Pico-SDK is by Raspberry Pi (Trading) Ltd and licensed under the BSD 3-Clause license.
- Arduino-Pico core files are licensed under the LGPL.