Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a way to control a VGA screen with a PIC. External components are OK, so a VGA chip with I2C or SPI or something is okay too.


  • Resolution: max 1024x768, no minimum
  • Language: C (C18 compiler) or Jalv2
  • Only text, no graphics necessary (but it would be okay if it had that too)
  • One colour is enough, so DA converting is out of the scope of this question

In my project I have a text buffer which I want to have on a screen. You can compare it to using an LCD display for text displaying, but now with VGA.

share|improve this question
What are you trying to do? A PIC does not have any video hardware, nor is there any de-facto standard video hardware used with PICs. Any software will be specific to a particular hardware setup. – Dave Tweed Jan 8 '13 at 14:03
The right PIC might be able to produce VGA signals with careful coding, but that won't be easy. What hardware do you intend to provide between the PIC and the VGA output? – Olin Lathrop Jan 8 '13 at 14:24
A text buffer of what dimensions? Can you dedicate most of the processor's power to servicing the display? Off the top of my head I'm not aware of self-contained "VGA chips" but you could make a self contained SPI or serial display slave with either a small FGPA or a second microcontroller, either one with a very high clock rate and/or DMA (some of the ARM cortex parts perhaps) or one designed for odd tasks such as a parallax propellor. If you are okay with limited colors, your elecrical interface can be just a few resistors. – Chris Stratton Jan 8 '13 at 15:32
One, to just offload the very busy task of constantly repainting the display to leave your primary processor free to contemplate what should be on the display. Two, because it's faster, has multiple cores, and people have done video displays with it. An FPGA would give even more flexibility, but has a high learning curve and is substantially more expensive including support components. – Chris Stratton Jan 8 '13 at 15:49
@Camil Staps Take a look at code for the Propeller Demo Board for example. It does PS/2 keyboard and mouse, displays on Composite output and VGA, samples from a microphone and plays back, all at the same time. Another place to look is the Object Exchange. There are many VGA objects there available for free. Also there are VGA demos which come with the IDE too. – AndrejaKo Jan 8 '13 at 16:02
up vote 3 down vote accepted

If it's not overkill for your application, you could add an ISA interface to your PIC and pick up an old video card somewhere.

However, supercat points out there's no PC to run the video BIOS, so probably this wouldn't work.

I did find a post on hackaday doing a similar thing with an AVR that might be good for inspiration.

share|improve this answer
Ooh, nice! Certainly have to think about this for future projects, thanks for linking & +1! I'm afraid it's an overkill for this project though.. – Camil Staps Jan 10 '13 at 14:22
Nice indeed, forgot all about that. I think there may even be VGA cards which can function with only the 8-bit ISA connected; there certainly are hercules, EGA, etc cards which might be able to be reprogrammed to the needed timings. – Chris Stratton Jan 10 '13 at 15:16
A sufficiently-antiquated VGA card should work with an 8-bit bus, but the I/O requirement for even an 8-bit bus is going to be sufficiently huge that one may as well spring for 16-bit access. A problem one is apt to have with VGA cards, though, is finding out what initialization sequence is required for any particular card. Even cards which are "100% VGA compatible" will often have to be initialized in various non-standard ways prior to use. Since every VGA card includes a BIOS ROM, this is not aproblem when the card is plugged into a PC; the PC will run the code in the ROM, which will... – supercat Jan 10 '13 at 17:09
...perform the appropriate initialization for any registers which did not exist on the original VGA. Unless you plan on writing an 8086-emulation library for your PIC, however, the initialization routines supplied in the ROM are apt to be quite useless. – supercat Jan 10 '13 at 17:10
@supercat you are probably right, I forgot about the video BIOS. – Phil Frost Jan 10 '13 at 17:12

It is likely that the circuitry required to add a VGA display to a PIC will exceed the cost and complexity of using a different chip which could provide a display and also do whatever the PIC was going to be doing, or else using something like a Raspberry Pi to provide the display and having it communicate with the PIC via a UART or something similar (I think the Raspberry PI has at least one UART among its I/O pins).

If your goal is to build yourself a VGA subsystem so you can learn how such things work, a VGA interface at 640x480 requires the ability to clock out about 32 million pixels/second. That's going to be a fair bit beyond the abilities of an "unassisted" PIC; you probably wouldn't have to add much hardware to a PIC to allow it to output text if you didn't mind having the display hogging up the processor during the majority of each frame, but the PIC likely wouldn't have time for anything else; each scan line would require that it execute a 160-instruction sequence something like:

movf  POSTINC0,w,c
movwf PORTC,c

starting on just the right cycle, and running without interruption [hardware would blindly grab character data from PORTC at the moment it was supposed to be there, feed it through a character-shape ROM, and load it into a shift register].

If you did something like that, it might be possible for a 32MHz PIC to generate 80x25 text using something like a fast (25ns) 32Kx8 ROM to hold character shapes and serialize them, a 3-bit counter to clock out the pixels of each character, and a few miscellaneous gates; one could probably use one of the PIC's PWM modules to handle horizontal sync. This approach would provide an 80x25 matrix of tiles which could each be any of 256 shapes; each shape would be 8x16 pixels, and any combination of 256 colors [for simplicity, figure the colors would probably be RRRGGGBB or something like that]. If one had trouble finding a fast enough 32Kx8 ROM, one could use a fast 32Kx8 RAM instead, and provide a mechanism for feeding data into it on system startup.

share|improve this answer
But Raspberry Pi doesn't do VGA. – AndrejaKo Jan 10 '13 at 16:06
@AndrejaKo: Ah, okay. If you need VGA in particular, there are probably still some other single-board computers which could do the job for less than the cost of engineering a custom solution. Going the PIC route may be educational, though. The quantity of circuitry shouldn't be unreasonable, and you could probably still find everything you need in easy-to-hand-solder through-hole parts. BTW, adding some counters, an off-chip RAM, and a little glue logic would make it possible to have the video generated continuously without PIC involvement, with the caveat that the PIC... – supercat Jan 10 '13 at 16:43
...would have to properly time its display writes to ensure that they coincided with the times display data was available; adding a bit more circuitry could ease that requirement. – supercat Jan 10 '13 at 16:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.