cancel
Showing results for 
Search instead for 
Did you mean: 

Interfacing STM32F429DISCO with a different LCD

Lori B.
Associate III
Posted on October 13, 2014 at 17:10

Hi everybody! I'm working on a project based on the STM32F429DISCO board.

I need to interface it with a bigger lcd. I developed a board to interface the STM32F429DISCO with the LCD using the same pins of the 24bit interface. I'm now trying to adapt the project, but I can't get the display to perform properly. I only get noisy horizontal lines. I tought I was enough to change the resolution and the timing setting of the LTDC periph, but I'm missing something for sure. I can't understand what it is. This is the LCD: http://www.schurter.it/Downloads/Datasheet/KWH043ST12-F03%20V.2.PDF And this is what I changed in my code (in the stm32f429i_discovery_lcd.c file).

#define HBP 2 

#define VBP 2 

#define HSW 41 

#define VSW 10 

#define HFP 2
#define VFP 2
#define XSIZE_PHYS 480
#define YSIZE_PHYS 272 

/**
* @brief Initializes the LCD.
* @param None
* @retval None
*/
void LCD_Init(void)
{ 
LTDC_InitTypeDef LTDC_InitStruct;
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable clock for NCS port */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
/* Configure NCS in Output Push-Pull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* Configure the LCD Control pins ------------------------------------------*/
LCD_CtrlLinesConfig();
LCD_ChipSelect(DISABLE);
LCD_ChipSelect(ENABLE);
/* Configure the LCD_SPI interface -----------------------------------------*/
LCD_SPIConfig(); 
/* Power on the LCD --------------------------------------------------------*/
LCD_PowerOn();
/* Enable the LTDC Clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE);
/* Enable the DMA2D Clock */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE); 
/* Configure the LCD Control pins */
LCD_AF_GPIOConfig(); 
/* Configure the FMC Parallel interface : SDRAM is used as Frame Buffer for LCD */
SDRAM_Init();
/* LTDC Configuration *********************************************************/ 
/* Polarity configuration */
/* Initialize the horizontal synchronization polarity as active low */
LTDC_InitStruct.LTDC_HSPolarity = LTDC_HSPolarity_AL; 
/* Initialize the vertical synchronization polarity as active low */ 
LTDC_InitStruct.LTDC_VSPolarity = LTDC_VSPolarity_AL; 
/* Initialize the data enable polarity as active low */
LTDC_InitStruct.LTDC_DEPolarity = LTDC_DEPolarity_AL; 
/* Initialize the pixel clock polarity as input pixel clock */ 
LTDC_InitStruct.LTDC_PCPolarity = LTDC_PCPolarity_IPC;
/* Configure R,G,B component values for LCD background color */ 
LTDC_InitStruct.LTDC_BackgroundRedValue = 0; 
LTDC_InitStruct.LTDC_BackgroundGreenValue = 0; 
LTDC_InitStruct.LTDC_BackgroundBlueValue = 0; 
/* Configure PLLSAI prescalers for LCD */
/* Enable Pixel Clock */
/* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
/* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAI_N = 192 Mhz */
/* PLLLCDCLK = PLLSAI_VCO Output/PLLSAI_R = 192/4 = 48 Mhz */
/* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = 48/8 = 6 Mhz */
RCC_PLLSAIConfig(192, 7, 4);
RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div8);
/* Enable PLLSAI Clock */
RCC_PLLSAICmd(ENABLE);
/* Wait for PLLSAI activation */
while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET)
{
}

/* Configure horizontal synchronization width */ 
LTDC_InitStruct.LTDC_HorizontalSync = HSW;
/* Configure vertical synchronization height */
LTDC_InitStruct.LTDC_VerticalSync = VSW;
/* Configure accumulated horizontal back porch */
LTDC_InitStruct.LTDC_AccumulatedHBP = HSW + HBP; 
/* Configure accumulated vertical back porch */
LTDC_InitStruct.LTDC_AccumulatedVBP = VSW + VBP; 
/* Configure accumulated active width */ 
LTDC_InitStruct.LTDC_AccumulatedActiveW = HSW + HBP + XSIZE_PHYS;
/* Configure accumulated active height */
LTDC_InitStruct.LTDC_AccumulatedActiveH = VSW + VBP + YSIZE_PHYS;
/* Configure total width */
LTDC_InitStruct.LTDC_TotalWidth = HSW + HBP + XSIZE_PHYS + HFP; 
/* Configure total height */
LTDC_InitStruct.LTDC_TotalHeigh = VSW + VBP + YSIZE_PHYS + VFP;
LTDC_Init(<DC_InitStruct);
} 
/**
* @brief Initializes the LCD Layers.
* @param None
* @retval None
*/
void LCD_LayerInit(void)
{
LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct; 
/* Windowing configuration */
/* In this case all the active display area is used to display a picture then :
Horizontal start = horizontal synchronization + Horizontal back porch = 30 
Horizontal stop = Horizontal start + window width -1 = 30 + 490 -1
Vertical start = vertical synchronization + vertical back porch = 4
Vertical stop = Vertical start + window height -1 = 4 + 320 -1 */ 

LTDC_Layer_InitStruct.LTDC_HorizontalStart = HBP + 1;
LTDC_Layer_InitStruct.LTDC_HorizontalStop = (LCD_PIXEL_WIDTH + HBP);
LTDC_Layer_InitStruct.LTDC_VerticalStart = VBP + 1;
LTDC_Layer_InitStruct.LTDC_VerticalStop = (LCD_PIXEL_HEIGHT + VBP);


/* Pixel Format configuration*/
LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565;
/* Alpha constant (255 totally opaque) */
LTDC_Layer_InitStruct.LTDC_ConstantAlpha = 255; 
/* Default Color configuration (configure A,R,G,B component values) */ 
LTDC_Layer_InitStruct.LTDC_DefaultColorBlue = 0; 
LTDC_Layer_InitStruct.LTDC_DefaultColorGreen = 0; 
LTDC_Layer_InitStruct.LTDC_DefaultColorRed = 0; 
LTDC_Layer_InitStruct.LTDC_DefaultColorAlpha = 0;
/* Configure blending factors */ 
LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA; 
LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_CA;
/* the length of one line of pixels in bytes + 3 then :
Line Lenth = Active high width x number of bytes per pixel + 3 
Active high width = LCD_PIXEL_WIDTH 
number of bytes per pixel = 2 (pixel_format : RGB565) 
*/
LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((LCD_PIXEL_WIDTH * 2) + 3);
/* the pitch is the increment from the start of one line of pixels to the 
start of the next line in bytes, then :
Pitch = Active high width x number of bytes per pixel */ 
LTDC_Layer_InitStruct.LTDC_CFBPitch = (LCD_PIXEL_WIDTH * 2);
/* Configure the number of lines */ 
LTDC_Layer_InitStruct.LTDC_CFBLineNumber = LCD_PIXEL_HEIGHT;
/* Start Address configuration : the LCD Frame buffer is defined on SDRAM */ 
LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER;
/* Initialize LTDC layer 1 */
LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct);
/* Configure Layer2 */
/* Start Address configuration : the LCD Frame buffer is defined on SDRAM w/ Offset */ 
LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER + BUFFER_OFFSET;
/* Configure blending factors */ 
LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA; 
LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA;
/* Initialize LTDC layer 2 */
LTDC_LayerInit(LTDC_Layer2, <DC_Layer_InitStruct);
/* LTDC configuration reload */ 
LTDC_ReloadConfig(LTDC_IMReload);
/* Enable foreground & background Layers */
LTDC_LayerCmd(LTDC_Layer1, ENABLE); 
LTDC_LayerCmd(LTDC_Layer2, ENABLE);
/* LTDC configuration reload */ 
LTDC_ReloadConfig(LTDC_IMReload);
/* Set default font */ 
LCD_SetFont(&LCD_DEFAULT_FONT); 
/* dithering activation */
LTDC_DitherCmd(ENABLE);
}

I'm using STemWIN and I noticed that also the GUIDRV_stm32f429i_discovery file as a similar part as above called during the GUI_Init function. I also changed the timing settings of this part to work as the same as the first file. Thanks for your help!
3 REPLIES 3
Posted on October 13, 2014 at 17:39

Doesn't the manual suggest it needs/expects a 9 MHz pixel clock?

You might be better reviewing the 480x272 display on the STM32F4x9I-EVAL

STM32F4xx_DSP_StdPeriph_Lib_V1.4.0\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval_lcd.c
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Lori B.
Associate III
Posted on October 14, 2014 at 10:17

Hi clive1! Thank you that's a good point! Unfortunately I changed my code to

RCC_PLLSAIConfig(192, 7, 5);

  RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div4);

but it doesn't work anyway..

I started looking at the EVAL lcd file, but it looks very similar to what I wrote..

Lori B.
Associate III
Posted on October 14, 2014 at 17:44

I'm starting to think that the problem is not in the lcd initialization (infact I'm able to get simple LTDC examples working) but in the driver used by emWIN..

I'm using GUIDRV_Lin, but I ca't understand if it's ok for this LCD since its datasheet doesn't say which controller it uses.

Is it possible? Is there a way out since I wouldn't be able to write my own driver?