ChrimboProject: VGA output on STM32F103 (Bluepill) - Page 1
Forum section: electronics / general

author: mubes
author_rank: Regular Contributor
timestamp: January 10, 2019, 04:28:51 pm
content: With a few evenings to spare over Christmas, the kids engrossed in techtoys and not much on TV I thought I'd have a go at some VGA output from a jellybean CORTEX-M3. You can see the result below;https://youtu.be/5UFpp3ao460On the STM32F103C8 you can sensibly get 50x18 video using about 24% of the CPU, around 1200 bytes of RAM and 3-7K of Flash (depending on how many characters you need in your character set).It's BSD licensed and intended for use as a drop in option during system development and debug. There are pretty minimal text and graphic screen manipulation routines built in. A writeup about it which includes a few tricks about monitoring CPU loading is available fromhttp://shadetail.com/blog/vga-video-out-on-bluepill/, and there are links to the code there too, if anyone finds that kind of thing interesting.Comments and not too many brickbats appreciated.DAVE

author: SiliconWizard
author_rank: Super Contributor
timestamp: January 10, 2019, 05:07:23 pm
content: Nice stuff.Just a quick question (haven't read the whole description): from the video, the actual resolution seems to be quite higher than 50x18, so not sure I got exactly how you did it. Or maybe you didn't mean that in pixels. Or maybe I didn't get what you mean overall.

author: mubes
author_rank: Regular Contributor
timestamp: January 10, 2019, 05:16:27 pm
content: The overall resolution is 800x600, and you _can_ get very high resolution out of the device but it puts it on its knees. As a compromise I doubled up in X (==400 pixels) and in Y too (==300 pixels) and then use a 8x16 font, hence 50x18(+fudge) in text cells. If you uncomment the 'HIRES' define in the source you can have the full 100 char goodness, and if you reduce the Y-multiplier then you can increase the Y res too....but 50x18 is the sweet spot for this particular chip.The video is on a small (9" ?) monitor, so it flatters the chunkyness of the pixels...)DAVE

author: SiliconWizard
author_rank: Super Contributor
timestamp: January 10, 2019, 11:40:14 pm
content: Alright, thanks for the clarification.Well I suppose your code is portable to other devices, at least to other STM32 MCUs without too much effort. So on beefier ones (such as STM32F4 or F7) you could probably get higher resolution, add colors, and so on.

author: mubes
author_rank: Regular Contributor
timestamp: January 11, 2019, 08:37:34 am
content: Quote from: SiliconWizard on January 10, 2019, 11:40:14 pmDefinitely. Porting should be reasonably trivial. The whole of vidout.c (which actually drives the VGA) is only 314 lines, of which probably 50% are comments. The routine in the middle of it which is responsible for the timing is only 34 C-code lines long and there are only three routines (one setup and two interrupt handlers) that are processor specific....it really shouldn't be a painful exercise.In terms of performance, if you look at what Cliff Biffle was able to achieve with Glitch (Athttp://cliffle.com/article/2015/06/05/introducing-glitch/) then 256-colour full res VGA has already been demonstrated to be possible on beefier chips. I'm reasonably sure that something like an LPC43xx or IMXRT could do the vast majority of the work needed with virtually no processor intervention at all.The intention was never to create something for end user applications though - I was really just wanting something more immediate than a serial port for debug purposes, and 50x18 in mono is quite enough for me for that...although I do have an itch to create a single chip VT340 at some point, perhaps based off the stuff by Geoff Graham (http://geoffg.net/terminal.html) or one of the other projects that's already floating around out there.DAVE