stm32f429zg板子,显示RGB565格式图片,有水纹印

2019-07-20 07:41发布

QQ图片20160320155606.jpg
如题,429ZG板子,驱动七寸液晶,外扩sdram做显存。显示565图片,有失真,不知有大神做过类似的或有相同问题的,来探讨下
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
23条回答
shitailu2008
1楼-- · 2019-07-20 13:21
可能是某个LTDC或者FMC的某个管脚复用配置没有设置好,我之前出现竖条的水波纹,后来检查发现是FMC的有一个管脚复用配置错了 。你可以调试看一下SDRAM中的数据对不对
纯乐乐24k
2楼-- · 2019-07-20 18:05
 精彩回答 2  元偷偷看……
taizonglai
3楼-- · 2019-07-20 19:44
 精彩回答 2  元偷偷看……
纯乐乐24k
4楼-- · 2019-07-21 00:25
zuozhongkai 发表于 2016-3-20 21:07
估计是LTDC的配置有问题,看你 第二张图的颜 {MOD}都不正常啊,灰 {MOD}都不是灰 {MOD}了

嗯嗯,正在查,但是LTDC的RGB565配置只有那么点,想不出哪里出错
纯乐乐24k
5楼-- · 2019-07-21 05:55
void LCD_Init(void)
{
  LTDC_InitTypeDef       LTDC_InitStruct;

  /* Configure the LCD Control pins ------------------------------------------*/
  //LCD_CtrlLinesConfig();

  /* 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);

  //26.4 x 2 x 4 = 211  //290
RCC_PLLSAIConfig(244, 7, 3);
  RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div2);
//RCC_PLLSAIConfig(360, 7, 3);
// RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div4);
  //32*3*2 = 192
  //RCC_PLLSAIConfig(192, 7, 3);  
// RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div2);  

  /* Enable PLLSAI Clock */
  RCC_PLLSAICmd(ENABLE);
  /* Wait for PLLSAI activation */
  while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET)
  {
  }

  /* Timing configuration */  
  /* Configure horizontal synchronization width */     
  LTDC_InitStruct.LTDC_HorizontalSync =LCD_HS;//30;//9;
  /* Configure vertical synchronization height */
  LTDC_InitStruct.LTDC_VerticalSync = LCD_VS;//15;//1;
  /* Configure accumulated horizontal back porch */
  LTDC_InitStruct.LTDC_AccumulatedHBP = LCD_HBP;//46;//29;
  /* Configure accumulated vertical back porch */
  LTDC_InitStruct.LTDC_AccumulatedVBP = LCD_VBP;//23;//3;  
  /* Configure accumulated active width */  
  LTDC_InitStruct.LTDC_AccumulatedActiveW = LCD_AW;//269;
  /* Configure accumulated active height */
  LTDC_InitStruct.LTDC_AccumulatedActiveH = LCD_AH;//323;
  /* Configure total width */
  LTDC_InitStruct.LTDC_TotalWidth = LCD_TOTAL_W;//200;//1055;//279;
  /* Configure total height */
  LTDC_InitStruct.LTDC_TotalHeigh = LCD_TOTAL_H;//20;//524;//327;

  LTDC_Init(&LTDC_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 + 240 -1
  Vertical start   = vertical synchronization + vertical back porch     = 4
  Vertical stop   = Vertical start + window height -1  = 4 + 320 -1      */      
  LTDC_Layer_InitStruct.LTDC_HorizontalStart = LCD_LAYER_H_START;
  LTDC_Layer_InitStruct.LTDC_HorizontalStop = LCD_LAYER_H_STOP;
  LTDC_Layer_InitStruct.LTDC_VerticalStart = LCD_LAYER_V_START;
  LTDC_Layer_InitStruct.LTDC_VerticalStop = LCD_LAYER_V_STOP;

  /* 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;
  //
  //memcpy((unsigned char*)LCD_FRAME_BUFFER, gImage_photo, sizeof(gImage_photo));
  //memcpy((unsigned char*)(LCD_FRAME_BUFFER + BUFFER_OFFSET), gImage_photo, sizeof(gImage_photo));
  //
  /* Start Address configuration : the LCD Frame buffer is defined on SDRAM */   
  LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER;//BACKGROUND_PIC_ADD  LCD_FRAME_BUFFER;
  //
  //memset((unsigned char*)LCD_FRAME_BUFFER, 0, BUFFER_OFFSET*2);
  //
  /* Initialize LTDC layer 1 */
  LTDC_LayerInit(LTDC_Layer1, &LTDC_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);
}

纯乐乐24k
6楼-- · 2019-07-21 06:27
 精彩回答 2  元偷偷看……

一周热门 更多>