Color LCD

Contents: 
Subjects: 

This display is part G13752 from The Electronic Goldmine. The datasheet for the screen can easily be found online.

This screen has a resolution of 240x160 and 9-bit color. Pixels are clocked in one at a time. Pixel data consists of 3 bits for each color component. According to the datasheet, the screen requires supplies of 3.00V and 3.80V, but the absolute maximum ratings are generous and I have had no problems running both supplies at 3.3V. The screen has a connection for a microphone but the parts aren't there, so you could use it for something else.

Connection

I connected my screen to port A1 of a Digilent D2FT board via the pin headers on the breadboard add-on board.

Since the screen has a fine-pitch flex cable, I built an adapter by soldering a connector for the flex cable (Digi-Key part OR690CT-ND) onto a 0.5mm TSSOP-40 surface-mount adapter board (from BelDynSys P507). The connector has 22 pins but the adapter board only has 20 pads on one side, so I left the two microphone pins hanging off the end of the row of pads. When connecting the flex cable, the copper pads point towards the board.

Color LCD connector
The connector and adapter board for the color LCD screen.
The two unconnected pins are on the right.
All color LCD hardware
The complete setup.

Both power supplies for the LCD screen (Vcc1 and Vcc2) are connected to 3.3V from the D2FT board. The LED backlight runs off unregulated power from the adapter (~7V in my case) through a 150-ohm resistor. This is really the wrong way to power the backlight, since there is no current regulation. According to the datasheet, the LEDs should be run at up to 15mA. My resistor provides only 6.7mA. At this current, the backlight drops 6.13V.

Code

The code consists of two VHDL files: test.vhd and lcd_sync.vhd.

test.vhd contains code specific to the D2FT board and my test code. It generates the LCD dot clock (MCLK) from the 50MHz clock provided by the board, does some simple animation, and connects signals from LCD_Sync to the LCD screen.

lcd_sync.vhd contains the code specific to this LCD screen. It generates the horizontal and vertical sync signals, keeps track of the position of the pixel currently being sent to the LCD screen, and generates a pixel enable signal so that the pixel data can be forced to zero when no visible pixel is being scanned out.

The datasheet shows the correct timing waveforms. The timing characteristics in the datasheet show that the sync pulses can have more convenient timing than the example waveforms show - the examples would require more tests on the pixel position that my code uses, but my code's output is within the datasheet's limits. The example waveforms show shorter sync pulses, but the Operating Conditions on page 8 indicate that the pulses can start at the end of visible data and continue until the last cycle before visible data is sent. This makes the sync generation code very simple.

The VHDL code can be downloaded here.

Color LCD running
The LCD with the test code running.

Notes

For some reason, outputting pixel data during a blanking interval causes the screen to get confused and the display is shifted. Outputting all zeros for pixel data when the horizontal or vertical position is outside the range of visible pixels prevents this. This is why the LCD_Sync module generates the pixel_en signal.

The line

led <= (led_counter(23) and led_counter(17) and led_counter(16) and led_counter(15)) or active;


in test.vhd is a neat trick: It makes the LED flash dimly when active is low, and stay on brightly when active is high. led_counter is a 24-bit counter clocked by the 50MHz clock provided by the D2FT board. The terms for bits 15-17 effectively pulse-width-module the LED. The term for bit 23 flashes the LED a few times per second. This is one of those things that are much simpler in hardware than in software.