Clock edge TFT LCD

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

  • Clock edge TFT LCD

    Hi,

    I'm working in a project with STM32f429ZIT6 and it controls a TFT LCD.

    I have a developed code from my old colleague and it works (with STM32F429 DISCOVERY board) and I can see through a chinese TFT (TFT 1) which I want. Ok.

    Currently I want to test another TFT (TFT 2) which has the same (exactly the same) pinout but I see blurred image and blinking. So, I compare the clock of the datasheet in each other, and it seems the first TFT works with falling egde clock and the second with rising edge clock.

    So, how I can change this configuration? is it possible?

    My TFTLCD_Init is configured as:

    C Source Code

    1. void TFTLCD_Init(void){ uint8_t i = 0; /* GPIO pin configuration */ while(GPIOInitTable[i] != 0){ gpio_conf(GPIOInitTable[i], PINInitTable[i], MODE_AF, TYPE_PUSHPULL, SPEED_100MHz, PULLUP_NONE, AFInitTable[i]); i++; } /* PLL */ RCC->PLLSAICFGR = (200 << 6) | (7 << 24) | (4 << 28); /* Enable SAI PLL */ RCC->CR |= RCC_CR_PLLSAION; /* wait for SAI PLL ready */ while((RCC->CR & RCC_CR_PLLSAIRDY) == 0); /* enable clock for LTDC */ RCC->APB2ENR |= RCC_APB2ENR_LTDCEN; /* Synchronization Size Configuration */ LTDC->SSCR = ((HSYNC - 1) << 16) | (VSYNC - 1); /* Back Porch Configuration */ LTDC->BPCR = ((HBP - 1) << 16) | (VBP - 1); /* Active Width Configuration */ LTDC->AWCR = (ACTIVE_W << 16) | (ACTIVE_H); /* Total Width Configuration */ LTDC->TWCR = (TOTAL_WIDTH << 16) | (TOTAL_HEIGHT); /* Window Horizontal Position Configuration */ LTDC_Layer1->WHPCR = HBP | ((HBP + LCD_WIDTH - 1) << 16); /* Window Vertical Position Configuration */ LTDC_Layer1->WVPCR = VBP | ((VBP + LCD_HEIGHT - 1) << 16); /* Pixel Format Configuration */ LTDC_Layer1->PFCR = 2; /* Color Frame Buffer Address */ LTDC_Layer1->CFBAR = SDRAM_BASE; /* Color Frame Buffer Length */ LTDC_Layer1->CFBLR = ((LCD_WIDTH * PIXELWIDHT) << 16) | ((LCD_WIDTH * PIXELWIDHT) + 3); /* Enable Layer */ LTDC_Layer1->CR = LTDC_LxCR_LEN; /* Immediate Reload */ LTDC->SRCR = LTDC_SRCR_IMR; /* Enable LTDC */ LTDC->GCR = LTDC_GCR_LTDCEN; /* Enable dither */// LTDC->GCR = LTDC_GCR_DTEN;}



    (I don't know why I can see here the code line to line instead of in a one line ?( )


    Thanks

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

  • Hi,

    According to the STM32F4 reference manual the LTDC_GCR register should be responsible for setting the polarity of HSYNC, VSYNC, DE and Pixel clock.

    Try this as list line in your init. Just umcomment the needed lines to set the proper bits:

    C Source Code

    1. /* Enable dither */
    2. LTDC->GCR = LTDC_GCR_DTEN
    3. // | (1 << 31) // Bit 31 HSPOL: Horizontal Synchronization Polarity
    4. // | (1 << 30) // Bit 30 VSPOL: Vertical Synchronization Polarity
    5. // | (1 << 29) // Bit 29 DEPOL: Data Enable Polarity
    6. // | (1 << 28) // Bit 28 PCPOL: Pixel Clock Polarity
    7. ;


    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 Schoenen

    I've just test it and I don't find the solution.

    I think maybe are these values:

    C Source Code

    1. #define HFP 18
    2. #define HSYNC 1
    3. #define HBP 70
    4. #define VFP 10
    5. #define VSYNC 1
    6. #define VBP 13



    What determines this values? Where I can know which is the HFP, HSYNC, HBP, VFP, etc?
  • I've found in the datasheet the HFP, HSYNC, HBP, VFP, VSYNC and VBP values as you can see in the following image. But I don't know if I work with NTSC or PAL system. How emWin works?

    In anycase, how I put decimal values?

    [img]https://i.imgsafe.org/b35afe6857.jpg[/img]


    The "Period" parameter, is there anyway to define it in the library?

    Thx
  • Hi,

    I've just become aware that when I copy your advices (the polarity), I copied it in:

    C Source Code

    1. /* Enable LTDC */
    2. LTDC->GCR = LTDC_GCR_LTDCEN | (1 << 31) // Bit 31 HSPOL: Horizontal Synchronization Polarity
    3. | (1 << 30); // Bit 30 VSPOL: Vertical Synchronization Polarity
    4. // | (1 << 29) // Bit 29 DEPOL: Data Enable Polarity
    5. // | (1 << 28) // Bit 28 PCPOL: Pixel Clock Polarity



    instead of

    C Source Code

    1. /* Enable dither */
    2. LTDC->GCR = LTDC_GCR_DTEN
    3. | (1 << 31) // Bit 31 HSPOL: Horizontal Synchronization Polarity
    4. | (1 << 30); // Bit 30 VSPOL: Vertical Synchronization Polarity
    5. // | (1 << 29) // Bit 29 DEPOL: Data Enable Polarity
    6. // | (1 << 28) // Bit 28 PCPOL: Pixel Clock Polarity



    Ok. As I've become aware of this error, I change it and put in the correct side, then apears two warnings which say:



    ..\Src\tftlcd.c(102): warning: #61-D: integer operation result is out of range

    | (1 << 31) // Bit 31 HSPOL: Horizontal Synchronization Polarity
    ..\Src\tftlcd.c(102): warning: #68-D: integer conversion resulted in a change of sign
    | (1 << 31) // Bit 31 HSPOL: Horizontal Synchronization Polarity
    what it means?

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

  • Hi,

    emWin doesn't 'know' anything about PAL or NTSC.

    emWin calculates raw data in form of color values and puts them into a framebuffer. How the LCD controller uses this data and how the LCD controller is initialized is not part of emWin itself.

    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.
  • Ok,

    so, I assume this is not the problem. In the following image you can see how it show currently my image in the TFT 2:

    [img]https://i.imgsafe.org/d6f81e7375.png[/img]


    Anybody have idea what configuration is not correct?

    Thanks
  • The following image is showing what apears with the same "C" code but in my board instead of STM32F429 DISCOVERY board. (The image which I can see with DISCOVERY board is in the last post).

    [img]https://i.imgsafe.org/db65b571e7.jpg[/img]


    I don't understand anything... why the same code, I've can see different images? if both work with TFT 1 perfectly...