The MicroVGA by Secons s.r.o. is a microcontroller-to-VGA adapter capable of producing a 800 by 600 at 60 Hz video output. The device displays a 16-color text mode screen of 80 by 25 characters. The MiniDIN6 connector can be used to plug in a PS/2 keyboard. The device operates at 5V TTL.
The device offers two interfaces for programming: UART and SPI. Older versions only offer the UART interface. Since we were unable to acquire a newer version, we used a MicroVGA rev. 3 UART-only module for writing this article.
The MicroVGA is great for connecting directly to a microcontroller. The TXD and RXD lines transfer the serial data. The RTS# line indicates whether the MicroVGA is ready to receive a data byte from the microcontroller. Thus the microcontroller must monitor RTS# each time it sends a data byte to the MicroVGA. The CTS# line indicates whether the MicroVGA is allowed to send a data byte to the microcontroller.
If you want to connect a MicroVGA to a PC, things may turn out less ideal. Most PCs of today don't have a serial port. And even if your PC does have one or more serial ports, these ports don't operate at 5V TTL so you can't hook up your MicroVGA without converting signal levels.
So you'll have to rely on a USB-to-serial adapter for hooking up your MicroVGA to your PC. Luckily there are plenty USB-to-serial adapters with 5V TLL UART available, allowing you to wire the MicroVGA directly to the adapter.
So what's the catch? As stated earlier, the RTS# line must be monitored for each byte that's transferred to the MicroVGA. This protocol works great for microcontrollers as they directly access I/O pins. However, when a USB bus is involved, the protocol introduces a serious performance bottleneck. The reason is that USB efficiently transfers lots of data bytes at once, but performs badly when it must send just one data byte at a time. Checking the RTS# line in-between data bytes will deteriorate performance even more.
To solve the problem, we came up with a solution that involves a microcontroller with dedicated firmware that sits between the MicroVGA and the USB bus. We used our AxiCat device as the bridge device. Note that you can use other hardware as well.
We've created a simple set-up for prototyping.
The MicroVGA is connected to UART0 on the AxiCat. The microcontroller can keep up with the data bytes coming from the MicroVGA, so CTS# is wired to ground. CS# is wired to ground as there's no need to deselect the MicroVGA.
The USB-to-UART adapter serves as a debug port. The firmware can be configured to print debugging information through this serial port to a terminal program on the PC.
The entire circuit is powered over USB and operates at 5 V level. Check the voltage selection jumper on the AxiCat before plugging in the USB cable.
All components wired together resulted in the board pictured next. We also added a reset button and shorted the BOOTLDR pads to speed up the firmware development cycle: compile -> download firmware -> run firmware -> test -> repeat.
The firmware assumes that the MicroVGA communicates at 115200 baud. You've to select the baudrate setting in the built-in setup tool of the MicroVGA. Don't forget to save after you've changed settings.
The firmware is part of the Public Software Repository.
In the source package, directory /public/axicat/axicat_microvga/ contains:
- axicat_microvga.c: C source file of the firmware.
- axicat_microvga.mk: Makefile.
- axicat_microvga.hex: HEX file for writing to the microcontroller's flash memory.
- axicat_microvga_data_01.raw: Test data for writing from your PC to the MicroVGA.
In the avr8 package, directory /public/bin/ contains:
- AxiCat-MicroVGA-1.0.0.hex: Intel HEX file for writing to the microcontroller's flash memory.
You can upload the HEX file to the AxiCat using the MCU Bootloader Tool. After you've put the AxiCat in bootloader mode, run the following command (serial path may differ on your system):
$ ./aximcubldr -v -serial /dev/ttyUSB0 -flash axicat_microvga.hex -run (Linux)
> aximcubldr.exe -v -serial \\.\COM4 -flash axicat_microvga.hex -run (Windows)
This is all you need to do to make the prototype board operational.
Hacking and Developing
You may be interested in hacking the C source, do your own development.
We use gcc-avr for developing the firmware. This tool set is available for Linux and Windows. WinAVR is an installable gcc-avr port for Windows. For Linux, the latest version of gcc-avr is usually available through the package manager. If you're using apt-get, run this command to install the tool set:
$ sudo apt-get install gcc-avr binutils-avr avr-libc
Debug-printing over UART1 is disabled in the C source. If you want to generate debug-prints, then you have to uncomment the #define DBG statement and compile. You can use a terminal program like Putty on your PC to see debug-prints.
Use make to build the C source in directory /public/axicat/axicat_microvga/. The command is the same in Linux and Windows:
$ make -f axicat_microvga.mk (Linux)
> make -f axicat_microvga.mk (Windows)
If you get a complaint about an unknown target processor then your version of avr-libc doesn't support the atmega164a. You've to change the MCU variable in the makefile from atmega164a to atmega164p to make it work.
Using the Hardware
Straightforward I/O with the MicroVGA
The solution presented here allows you to simply write bytes to and read bytes from the MicroVGA over a serial port. You don't need to worry about the RTS# line or other low-level stuff.
The zip file includes a file with test data that you can write to the MicroVGA:
$ cat axicat_microvga_data_01.raw > /dev/ttyUSB0 (Linux)
> copy axicat_microvga_data_01.raw \\.\COM4 (Windows)
The MicroVGA will display this:
In Linux, you can use the solution as a terminal:
$ sudo /sbin/getty -L -8 9600 ttyUSB0 vt100 &
A login prompt will appear on the VGA screen. The MicroVGA now is a terminal attached to your Linux system.
As you can see in the screenshot we created a new user named microvga. This is not absolutely necessary as you can log in with your regular account, but having a dedicated account allows you to set up an environment that suits the MicroVGA better as a terminal.
Note that the MicroVGA only supports a limited set of terminal escape sequences; some "colorful" text mode commands and programs won't be displayed correctly. Also note that the "Password" line appears indented; apparently the operating system doesn't send a carriage return (character code 13) at this point.
An interesting features is waking up the system. The AxiCat supports USB remote wake-up. This means you can wake up a "sleeping" operating system by pressing a button on the keyboard that's connected to the MicroVGA. For this to work, your operating system must be capable of waking up from a USB resume signal.
We've tested this feature successfully on a Windows XP system. We were able to wake up Windows from standby mode by hitting a button on the keyboard connected to the MicroVGA.
The solution presented in this article opens the door to a variety of interesting applications. The most important feature of the solution is the ability to access the MicroVGA from a PC by simply writing bytes to and reading bytes from the serial port without having to worry about the RTS# line.