A weblog focused on interesting circuits, ideas, schematics and other information about microelectronics and microcontrollers.
LPC2138 as a VGA controller
An LPC2138 microcontroller generates the VGA signals that drive the monitor as well as the graphics and fonts. The microcontroller also handles a keyboard, a mouse and some storage memory.
With a little bit of software magic the LPC2138 can be pressed into generating the VGA signals needed to drive a monitor plus handle all the font and graphics rendering. We do need to set some limits though, for instance 16 million colors sounds great but that means 3 bytes per pixel, 8-bits for red, 8 for green, and 8 for blue. If we tried to display 640x480 pixels that would be 307,200 pixels, which would then be multiplied by 3 bytes/pixel which then requires almost 1MB of RAM.
On the LPC2138 a PWM channel is setup to generate the Horizontal sync pulse and also interrupt the processor. The interrupt routine then outputs the video data for that line and keeps track of which line it's on for blanking and vertical sync purposes. The vertical sync pulse only has to occur once a frame at 60 frames a second so it is generated from the interrupt routine. Normally, all this video timing generation would keep most processors too busy to do anything else, not so with the LPC2138.
In between all the actual video data there are lots of blanks, so the processor doesn't really have to do anything except respond to the interrupt, do a little housekeeping, and then it can get back to what it was doing. This allows enough time to service all the normal interrupts and run foreground processes such as font rendering and running actual user code.