800 X 600 VGA With The STM32F4

Generating VGA is a perennial favorite on the Hackaday tips line, and it’s not hard to see why. Low-res video games, of course, but sending all those pixels out to a screen is actually a pretty challenging feat of coding. The best most project have attained is the original VGA standard, 640×480. Now that we have fast ARMs sitting around, we can bump that up to 800×600, like [Karl] did with an STM32F4 Discovery board.

The problem with generating VGA on a microcontroller is the pixel frequency – the speed at which pixels are shoved out of the microcontroller and onto the screen. For an 800×600 display, that’s 36 MHz; faster than what the 8-bit micros can do, but a piece of cake for the STM32F4 [Karl] is using.

[Karl] started his build by looking at the VGA project Artekit put together. It too uses an STM32, but a 36-pin F103 part. Still, it was fast enough to generate a line-doubled 800×600 display. [Karl] took this code and ported it over to the F4 part on the Discovery board that has enough space for a full 800×600 frame buffer.

With all that RAM on board the F4 part, [Karl] was able to expand the frame buffer and create a relatively high-resolution display with DMA and about a dozen lines of code. It looks great, and now we just need a proper application for high-resolution VGA displays. Retrocomputing? A high-resolution terminal emulator? Who knows, but it’s a great use for the STM32.

If circles and some text aren’t your thing, Artekit also has Space Invaders running on the 36-pin STM32.

12 thoughts on “800 X 600 VGA With The STM32F4

  1. Couldn’t one bang it out with high speed logic from a ram module and then write to it from a low speed uc during vblank period? Especially using a single line/address bit as an offset so that you can write to one frame buffer slowly while the high speed stuff screams through another. Or would that not work?

      1. Nowadays the simple & cheap way is to just use a display driver with integrated frame buffer and digital interface all the way. No point to convert to VGA unless one wants to use an old CRT as a display.

    1. The output side is not so much bit banging – you’re actually using a binary counter to convert RAM to a large Addressable Parallel In / Serial Out Register.

      If the fast logic can do one line then the MCU only has to intervene a couple of times per line for the output gate and sync pulse. The timing of the intervention is critical so you will probably have to write this in assembly or do a lot of trial and error with interrupts in C.

      Older (retro) computers were only 1 MIPS or less so it was common to leverage the CPU over the frame buffer. One way was to have 8×8 character bit maps in ROM (or RAM) and change one byte to change the ASCII (chr index) value and hence one write from the CPU changes 8 bytes of frame information.

      Modern 8 bit MCU are much faster PIC’s are about 4-5 MIPS, ATmega’s are about 16 – 20 MIPS. ATmega’s are also quite friendly to overclocking but the internal crystal oscillator runs out of steam quickly so if you use an external active crystal oscillator then they will clock at 30 MHz or faster.

      On the frame buffers input side you have to worry about how fast the MCU can update pixels. If your color depth is too great then the MCU won’t finish writing changes to one frame before the next starts. Mono is 8 pixels per byte, 4 color is 4 pixels per byte, 16 color is 2 pixels per byte … true color is 3 bytes per pixel. 256 color is generally easier.

    1. Any modern VGA* monitor will do this resolution as it’s an old standard.

      Most monitors are called VGA* when in fact they’re a higher resolution that supports all the lower resolutions.

      Their real* names are –
      QVGA 320:240 4:3
      VGA 640×480 4:3
      SVGA 800×600 4:3
      XGA 1024:768 4:3

      Other standards like WXGA are wide screen and don’t have the 4:3 aspect ratio.

      This article uses a 36MHz dot (pixel) clock so it probably has a vertical (frame) refresh rate of 50Hz.
      800×600 is also supported in 72Hz frame rate with a dot clock of 50MHz which makes it easier to get a crystal and peal off different frequencies for MCU clock etc.

    2. For CRT, it is true. Their scan rates can handle a wide range.

      At some point, digital monitors might no longer have analog inputs. Cheap LCD/LED TV (vs a monitor) with VGA input might not support all the formats. My $100 TV doesn’t like the screen modes (even for bios boot screen) on some of my old computers.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.