Tuesday, December 29, 2015

Colour Coding - Part V

In this post I will take you though the process of getting the FT812 SVGA shield up and running.

But first a little success story..........

SVGA Shield generates a big red blob!

Building the SVGA shield hardware was fairly quick - but what I didn't anticipate was a 16 hour day with a couple of false starts before I got it to produce it's first image.


It's always the case when you produce a new board design - that feeling of concern whether you have actually managed to get all the tracks right and everything connected correctly.

In the case of a break out board - this risk is minimised - because you have access to every pin on the IC - in theory.  However, in this case, because of the tight tracking around the QFN package, I had omitted to bring out some of the unused tracks - those involved with the clocking and latching of data to the non-present LCD. It was a gamble - but fortunately it paid off.

What I hadn't anticipated was the difficulty of soldering down the QFN package. Whilst it might look soldered - there is the chance that not all the pads have correctly wicked the solder under the package - and there were indeed, about half a dozen pads which required some remedial work.

A tip for the future is to use slightly longer pads for the QFN.  This ensures that there is perhaps 0.5mm of pad extending beyond the package - and it makes it so much easier to run additional flux and solder underneath the package with a manual soldering iron.

Unfortunately one of the non-soldered pads was VCCIO2 - which is a VCC power supply pin that supplies power to approximately half the chip - including all the RGB outputs, the Hsync and the Vsync.  This meant that a lot of time was wasted trying to fight unfamiliar firmware wondering why half the IC wasn't working.

Apart from the unsoldered pads, which were eventually traced and re-soldered, the layout of the pcb is essentially correct - so I have faith that I now have a "working wireless".


The firmware is based on the example supplied by FTDI for their Application Note AN 312.

This is intended to work with the STM32F407 Discovery Board - and as I already have several of these, it is quite a good place to start.

The firmware is based on their generic FT8xx hardware abstraction layer - which covers all the ICs in the FT8xx and FT81x range.  A header file FT800.h contains all the register names - but these memory mapped  registers are different for the FT80x and FT81x - so you have to make sure you select the correct set. It took me quite a while to establish exactly what set I needed, and to deselect the ones I didn't.

Once this was done, the chip started to show signs of life, and the 12MHz external crystal oscillator sprang into life.  The firmware reads back the chip ID - and if it doesn't see "7C" returned over the SPI bus - it knows that there is a fault, and halts.  I chose this to light up a red LED - so I knew that when the red LED went out - all was correctly set up.

Video Timing

The FT812  is a very versatile IC and can produce screen resolutions of up to 800x600 pixels, however, it needs a bit of setting up so that it's video output is something that a multi-sync monitor can actually sync to.

After quite some considerable experimentation with different sync timings and pixel clock frequencies I found that I could generate 800x600  56Hz with sufficient accuracy that the monitor would accept it. Some of the video standards use a positive going sync pulse - and the timing registers for this had to be carefully adjusted to get the right duration and timing.

The parameters I finally arrived at are as follows:

   //  SVGA // 800 x 600 56Hz VGA display parameters
  lcdWidth   = 800; // Active width of LCD display
  lcdHeight  = 600;        // Active height of LCD display
  lcdHcycle  = 952;       // Total number of clocks per line
  lcdHoffset = 96; // Start of active line
  lcdHsync0  = 0; // Start of horizontal sync pulse
  lcdHsync1  = 890; // End of horizontal sync pulse

  lcdVcycle  = 625; // Total number of lines per screen
  lcdVoffset = 2; // Start of active screen
  lcdVsync0  = 0; // Start of vertical sync pulse
  lcdVsync1  = 623; // End of vertical sync pulse
  lcdPclk    = 2; // Pixel Clock
  lcdSwizzle = 0; // Define RGB output pins
  lcdPclkpol = 1; // Define active edge of PCLK

These were used with the external 12MHz crystal oscillator, and the sync timings are approximate - and could possibly be better tuned.

Next Steps

The FTDI test code has allowed me to get the board up and running and produce my first video output. The code was relatively easy to understand - if not somewhat verbose, plus the fact that it catered for about 6 different ICs across several platforms - so was a little more complicated than it need have been.

The next step is to incorporate the GameDuino2  code Library - written for Arduino platforms etc - which will allow a somewhat higher level access to the video effects that the FT812 is capable of. This will be the subject of the next post.

It should be possible to port the GD2 library to mbed - and this would give immediate access to a very wide range of microcontrollers - including NXP, Freescale, Nordic etc.  It will also allow the SVGA shield to be used on the STM32F Nucleo boards,  Discovery F7 and the Maple Clones (STM32F103).

During testing, I also made good use of an old ATmega328 board I designed a few years back - the WiNode.  It's an uncluttered Arduino "clone"  that works at 3V3. I use these for quite a few small projects - as I have about 50 remaining in stock from an earlier project. They are in the form of a through hole kit - and can easily be soldered up in about half an hour.

The WiNode pcb can provide just the basics - a minimal 3V3 Arduino with access to the headers. This board will execute the GameDuino2 Library - with minimal modifications - and has the benefit of  a uSDcard holder on the underside of the board. There is also a battery backed RTC, 32Kx8 SRAM and an H-bridge that can be used as a class D digital amplifier for driving small speakers.  Adding video to such a useful board with further increase its application.

WiNode and SVGA Shield together for comparison

The SVGA shield concept works and is capable of producing an 800x600 SVGA video output for a monitor - using an IC that was really intended for compact LCD modules.

The hardware was simple and straightforward - the biggest problem was reliably soldering all the pads of the 56 pin QFN package.

The board can also accept a PS2 keyboard and mouse - and a welcome addition on a future version would be a microSDcard socket - allowing images to be down loaded from card.

The board works with a very basic 3.3V  SPI interface up to 30MHz  spi-clock - requiring just 5 signals - plus 3V3 and 0V.  It can be added to any microcontroller that presents the original Arduino expansion header pattern, with the SPI bus available on D11,D12, D13.

Some hours later - I could do this.....

1 comment:

Anthony said...

Very nice! I wonder if this could be used to provide video output for any custom cpu via memory mapping. Have you done anything with this?