Main Site Documentation

Non-GHI TFT Display with FEZ Spider II - RGB interface


#1

I’m trying to get a non-GHI display going using the RGB interface on the FEZ Spider II. I haven’t done much with this sort of thing, but it seems like I will have to write a new driver for the display (?), as it doesn’t use the same controller as the GHI modules (it’s an ST7789, which has different command codes).

Any advice on the most straightforward way to get this up and running? I tried following back the code for the TE35 gadgeteer module, but couldn’t find the the actual driver code to modify and create my own. I also couldn’t find much info on interfacing with the RGB interface of the FEZ board.

Any pointers towards a good place to start would be much appreciated.

Cheers.


#2

First of all, if the LCD supports an RGB interface with HSYNC and VSYNC etc then you don’t need any driver. The CPU directly supports this and all you need to do is input the timing for the LCD to the registers and it should just work.

The ST7789 is designed to support many different interfaces so make sure the LCD you have is setup for 16 bit RGB. If it is setup for one of the microcontroller interfaces you will need to do a lot more work and will need a driver.

What is the actual LCD you are using and what is the resolution?


#3

Hi Dave, thanks for your reply.

The display is an MCT028D0W240320PMLIPS, 240x320. According to the docs it is set up to support RGB. Assuming that a custom driver is not necessary, can you point me towards some part of the code that will let me interface with the RGB? I tried to follow the source back from Gadgeteer.Modules.Module.DisplayModule, but kind of hit a dead end.


#4

Have you set the parameters correctly for all the timing, and the pixel dimensions? Did you create a daughterboard for the R, G, B Gadgeteer sockets?


#5

Hi Brett, Everything is hooked up (hardware), I have all of the settings from the data sheet, I’m trying to work out the best way to code it, which code to use.


#6

Here’s an example of what I use on a 5" display. That should help you understand, there’s a couple of other references too…

        Display.Width = 800;
        Display.Height = 480;
        Display.HorizontalSyncPulseWidth = 48;
        Display.HorizontalBackPorch = 88;
        Display.HorizontalFrontPorch = 40;
        Display.VerticalSyncPulseWidth = 3;
        Display.VerticalBackPorch = 32;
        Display.VerticalFrontPorch = 13;
        Display.PixelClockRateKHz = 25000;
        Display.OutputEnableIsFixed = true;
        Display.OutputEnablePolarity = true;
        Display.HorizontalSyncPolarity = true;
        Display.VerticalSyncPolarity = true;
        Display.PixelPolarity = false;
        Display.Type = Display.DisplayType.Lcd;

        if (Display.Save())      // Reboot required?
        {
            PowerState.RebootDevice(false);
        }

(see https://www.ghielectronics.com/community/forum/topic?id=22465 and https://www.ghielectronics.com/docs/34/graphics#3267 for more info)


#7

How do you have IM2,1 and 0 connected? They should be 2=0, 1=1, 0=1 for the 18 bit interface. Note that the Spider uses 5 bits on R and B so you need to wire the lower bit to GND and use the upper 5 bits from the Spider.

I found this datasheet and the pinout page shows the colour connections.

The RGB timing you need for the settings Brett post are shown in this document.

Lastly, can you show how you have wired the display to the Spider?


#8

@ Brett - Ok, thanks, I did come across that way of configuring the display, I thought it wouldn’t work because the screen controller command codes weren’t specified anywhere. I will try again after I have checked the wiring pin assignments are correct.

@ Dave - Yes that’s one of the datasheets I’ve been referring to. I will recheck the connections though before I do anything else. I’ve inherited another developer’s work, it’s just the ribbon from the display broken out to pins, and the same for the gadgeteer plugs. I did a quick check when I first got hold of the rig, but I’ll do a thorough check of the wiring again to make sure.

One thing I’m confused about is where in the source the command codes for the display controller and the RGB interface related code live?

Thanks guys.


#9

There is no command codes. The output from the RGB interface is just a bit stream with timing. Pretty much the same as if you where using a VGA display on a PC. You only need to setup the correct timing as per the info Brett gave you and then you write to the screen buffer and magically you image etc will appear on your LCD.

See the section on DRAWING and TEXT at this link to get an idea of how you show stuff on the LCD. Glide is also another option for rapid GUI development.

https://www.ghielectronics.com/docs/34/graphics


#10

Well, so far there is nothing at all magically appearing, so seems like I still have something wrong. Here is the config I set up based on the datasheet:

public class Program
    {
        public static void Main()
        {
            Debug.Print("started.......");

            Debug.Print("Program Started");

            Display.Width = 240;
            Display.Height = 320;
            Display.OutputEnableIsFixed = true;
            Display.OutputEnablePolarity = false;
            Display.PixelPolarity = false;
            Display.PixelClockRateKHz = 635;
            Display.HorizontalSyncPolarity = false;
            Display.HorizontalSyncPulseWidth = 10;
            Display.HorizontalBackPorch = 20;
            Display.HorizontalFrontPorch = 10;
            Display.VerticalSyncPolarity = false;
            Display.VerticalSyncPulseWidth = 2;
            Display.VerticalBackPorch = 2;
            Display.VerticalFrontPorch = 4;
            Display.Type = Display.DisplayType.Lcd;
            Display.CurrentRotation = Display.Rotation.Normal;


            if (Display.Save()) Microsoft.SPOT.Hardware.PowerState.RebootDevice(false);

            Bitmap lcd = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);

            lcd.DrawEllipse(Colors.Red, 55, 55, 55, 55);

            lcd.Flush();

        }
    }

On a second look I’m not confident that I have the right polarities or pixelrate, should I be getting polarities from the timing diagrams?


#11

Could it be something as simple as the backlight not turned on?


#12

Hi Gus, As far as I can tell, the backlight is the only thing actually working, at least it lights up.


#13

First of all, your DOTCLK is too low. It should be 6.35Mhz

Try the pixel polarity for the sync as true.

You can also try different ones for the output enable polarity too. This is most likely to be true also.


#14

Another couple of days working on this, and trawling through data sheets and example code, and to get this display working at all with the RGB interface, I am having to configure it over SPI first, i.e. I have to send commands to set up the RGB mode etc. then turn display on. At that point I can send data on the RGB lines which is then displayed.

I still haven’t managed to get the settings right since the graphics are all displaying mirrored and the screen seems to be offset and wrapped around differently each time I restart. But I can see mirrored versions of the little info startup message now and anything I write to the screen, albeit in random locations on the display.

Any ideas on:
a) why the TE35 just works with RGB and no serial input to setup but I’m having to use SPI to configure this one? Is this something built-in to the TE35 by you guys, or just the ILI9340 chip has defaults that suit 565RGB (vs the ST7789V)?

b) which settings would be causing inversion and screen wrapping/offset?

Really appreciate the advice so far and any other ideas you guys might have.


#15

The TE35 is a pure RGB interface so it just works with the correct timing. It has no other options. Your display has the SPI and parallel as well as RGB so seems to need a bit more work. Someone else had a similar issue with another display with SPI too.

The mirroring is likely that the registers are still not quite correct. A bit more trawling of the datasheet might be needed.


#16

Got this working, thanks for the suggestions.

The display is designed for black background, so setting to that mode resolved some colour problems, and the important configuration setting to change was the RAM Control, which defaulted to a different kind of interface, and had to be changed to RGB.

I was also wondering if/where the code for the FEZ Spider II RGB interface was available?

Calling Flush() on a Bitmap in NETMF moves the pixel data into the relevant registers of the LPC1788 somehow, is this implemented with a C library specific to that chip? Is the source publicly available somewhere? Haven’t had much luck with my searches so far to find even any example code.