Using emwin library for TFT display

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Using emwin library for TFT display

    I have interfaced a 128*160 TFT screen(ST7735 controller) with LPC1768 MCU.Am using SPI interface to connect the MCU and display controller.To which pin of the MCU, should D/C pin be connected and how it must be configured in the code?

    The post was edited 2 times, last by RG97 ().

  • Hi,

    In general you can choose any pin which can be controlled by software and is not in use by other peripherals.

    Before sending a command or data over the SPI, just set this pin to the proper state.

    Regards,
    Sven
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Thanks for replying.
    Yeah, I did so but for some reason,the function GUI_init() is causing a hard fault and am not able to recognize the reason behind this.Am suing GUIDRV_FlexColor display driver.Here is the source code of LCDConf.c




    #define XSIZE_PHYS 160
    #define YSIZE_PHYS 128

    #define COLOR_CONVERSION GUICC_565
    #define DISPLAY_DRIVER GUIDRV_FLEXCOLOR




    void LCD_X_Config(void) {
    GUI_DEVICE * pDevice;
    GUI_PORT_API PortAPI = {0};
    CONFIG_FLEXCOLOR Config = {0};
    pDevice = GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER, COLOR_CONVERSION, 0, 0);
    if (LCD_GetSwapXY()) {

    LCD_SetSizeEx (0, YSIZE_PHYS, XSIZE_PHYS);
    LCD_SetVSizeEx(0, YSIZE_PHYS * NUM_VSCREENS, XSIZE_PHYS);
    } else {
    LCD_SetSizeEx (0, XSIZE_PHYS, YSIZE_PHYS);
    LCD_SetVSizeEx(0, XSIZE_PHYS, YSIZE_PHYS * NUM_VSCREENS);
    }
    PortAPI.pfWrite16_A0 = LCD_X_Write0_16;
    PortAPI.pfWrite16_A1 = LCD_X_Write1_16;
    PortAPI.pfWriteM16_A1 = LCD_X_WriteM1_16;
    PortAPI.pfReadM16_A1 = LCD_X_ReadM1_16;
    GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M18C0B9);
    Config.Orientation = DISPLAY_ORIENTATION;
    Config.RegEntryMode = 0;
    GUIDRV_FlexColor_Config(pDevice, &Config);
    }


    int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {

    int r;
    switch (Cmd) {

    case LCD_X_INITCONTROLLER: {
    _InitController();
    return 0;
    }
    default:
    r = -1;
    }
    return r;
    }
  • Hi,

    I can't say what is causing a hardfault.

    But there are some things I have noticed in your code:

    You have choosen GUICC_565 as color conversion which is 16bpp but you have configured the driver for 18bpp. Furthermore the last two parameters you have choosen are not compatible with each other.

    When using GUIDRV_FLEXCOLOR_F66709 you should choose one of these parameters:

    GUIDRV_FLEXCOLOR_M16C0B8
    GUIDRV_FLEXCOLOR_M16C1B8
    GUIDRV_FLEXCOLOR_M16C0B16
    GUIDRV_FLEXCOLOR_M16C1B16

    Please take a look at the description GUIDRV_FlexColor_SetFunc() in the emWin user manual in the display driver chapter.

    Regards,
    Sven
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Yeah, I changed that parameter and configured it for 16bpp but still it doesn't work out for me.:(Am working with LPC1768 which is a 32 bit MCU but the driver is configured for the 16-bit bus as there isn't way mentioned in the user manual to opt for the 32-bit bus using GUIDRV_FlexColor display driver.Also, there is reset pin for the LCD controller and I haven't connected it to any of the MCU pins. Could both these things be causing any problem?

    The post was edited 1 time, last by RG97 ().