MicroVGA

May 18, 2010

I got my MicroVGA display circuit today. This lets you output either SVideo or VGA text. The SVideo is in black and white and the VGA is text only and color. This is great to see whats going on and to have some fun ways to display test on tv’s and computer screens without any complications or having to take up a whole avr chip.

There was some issues out of the box, the first thing you should do when you get one is to connect the Arduino Gnd pin to pin 1 on the MicroVGA and 5V pin to pin 2. This will cause the unit to power up and output a display on both the VGA and SVideo outputs. Connect a convenient TV or monitor to one of the outputs and dig out an old PS/2 keyboard. The keyboard provides direct input to the MicroVGA for setup. Once you have this setup there are two contacts on the top of the board by pin 20 labeled “Setup”, put a wire across them and the output on the screen will switch to a menu that can be browsed with the keyboard. Select communications and change the value to SPI. There seems to be a display issue, after selecting SPI if you go back into the communications menu it still lists the wrong value but it is indeed selected. Restart by powering off / on and then you will be ready to setup your Arduino.

Once the SPI is enabled there were a few issues with the default library (the __builtin_avr_delay_cycles method was not defined). I found a nice answer on the Arudino Forums. Just in case there is an issue getting to the site here’s the code that should replace the existing arduino_uvga.c code in the microvga library for the Arduino.


// debugged 25/1/10 by Shaun Ruscoe
// changed 14/03/10 by Copabel for Arduino Mega.
// fixed 16/05/10 by Sh00rGEn

/*
This file implements low-level routines for Arduino MicroVGA-TEXT.

The MicroVGA has to be configured for SPI mode and connected as follows:

1 GND -> Arduino GND
2 +5V -> Arduino 5V
3 +3V3 NOT CONNECTED
4 CS# -> Arduino Digital 10 | Arduino Mega Digital 53
5 SCK -> Arduino Digital 13 | Arduino Mega Digital 52
6 RDY# -> Arduino Digital 8 | Arduino Mega Digital 10
7 MISO -> Arduino Digital 12 | Arduino Mega Digital 50
8 MOSI -> Arduino Digital 11 | Arduino Mega Digital 51

*/
#include "WProgram.h"
#include "conio.h"

#ifndef __builtin_avr_delay_cycles
void __builtin_avr_delay_cycles(unsigned long __n) {
while(__n)
__n--;
}
#endif

#if defined(__AVR_ATmega1280__)
// Arduino Mega Pin definitions

#define DD_SS 0 // PB0 | Arduino Mega Digital 53
#define DD_MOSI 2 // PB2 | Arduino Mega Digital 51
#define DD_MISO 3 // PB3 | Arduino Mega Digital 50
#define DD_SCK 1 // PB1 | Arduino Mega Digital 52
#define DD_RDY 4 // PB4 | Arduino Mega Digital 10

#else
// Arduino Duemilanove pin definitions

#define DD_SS 2 // PB2 | Arduino Digital 10
#define DD_MOSI 3 // PB3 | Arduino Digital 11
#define DD_MISO 4 // PB4 | Arduino Digital 12
#define DD_SCK 5 // PB5 | Arduino Digital 13
#define DD_RDY 0 // PB0 | Arduino Digital 8

#endif

#define DDR_SPI DDRB

void SPI_MasterTransmit(char cData)
{
/* Start transmission */
//SPDR = cData;
SPDR = cData;

/* Wait for transmission complete */
while ( ! (SPSR & (1<<SPIF)));
}

#define KEYBUF_SIZE 10
unsigned char keybuf[KEYBUF_SIZE];
unsigned char khead, ktail;

char kbhit;
int _getch()
{
int key;

while (!_kbhit()) ;

key = keybuf[khead];
khead++;
khead %= KEYBUF_SIZE;

if (key == 0) {
key = 0x100 | keybuf[khead];
khead++;
khead %= KEYBUF_SIZE;
}

return key;
}

int _kbhit()
{
if (khead == ktail)
_putch(0);

if (khead == ktail)
return 0;

if (keybuf[khead] == 0 && ((khead+1)%KEYBUF_SIZE) == ktail) {
_putch(0);
if (keybuf[khead] == 0 && ((khead+1)%KEYBUF_SIZE) == ktail)
return 0;
}

return 1;
}

void _putch(char ch)
{
unsigned char response;

__builtin_avr_delay_cycles(100);
PORTB &= ~(1<<DD_SS); // SS#=0
__builtin_avr_delay_cycles(100);
// wait for RDY signal to go low!
while (PINB & (1<<DD_RDY) );
__builtin_avr_delay_cycles(100);

/* Start transmission */
//SPDR = cData;
SPDR = ch;

__builtin_avr_delay_cycles(100);

/* Wait for transmission complete */
while ( ! (SPSR & (1<<SPIF)));
__builtin_avr_delay_cycles(100);

response = SPDR;
if (response != 0xFF) {
keybuf[ktail] = response;
ktail++;
ktail %= KEYBUF_SIZE;
kbhit = 1;
}

__builtin_avr_delay_cycles(100);

PORTB |= (1<<DD_SS); // SS#=0
}

void microvga_init()
{
kbhit = 0;
khead = 0;
ktail = 0;

/* Set MOSI and SCK output all others input
This agrees to AVR151 Table 1 also */

DDRB = (1<<DD_MOSI) | (1<<DD_SCK) | (1<<DD_SS);

DDRB &= ~(1<<DD_RDY);
DDRB &= ~(1<<DD_MISO); // MISO is always input

/* Enable SPI, Master, set clock rate fck/16 */
SPCR = (1<<SPE) | (1<<MSTR) | (1<<SPR0) | (1<<CPHA);

}

This should fix the compilation issues. The pin setup for this library is:

1 GND -> Arduino GND
2 +5V -> Arduino 5V
3 +3V3 NOT CONNECTED
4 CS# -> Arduino Digital 10 | Arduino Mega Digital 53
5 SCK -> Arduino Digital 13 | Arduino Mega Digital 52
6 RDY# -> Arduino Digital 8 | Arduino Mega Digital 10
7 MISO -> Arduino Digital 12 | Arduino Mega Digital 50
8 MOSI -> Arduino Digital 11 | Arduino Mega Digital 51

Here’s a couple pics of the board and the first image I got on the screen.

MicroVGA Board

MicroVGA Board

MicroVGA Dalek

MicroVGA Dalek


(yes… Exterminate is blinking…)

About these ads

One Response to “MicroVGA”

  1. george leung said

    I can see that this board has two ICs, can you disclose this two IC name ?? Thanks !!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: