stm32f429驱动TFT后小部分显示不正常

2019-07-14 17:04发布

/* IO¿Ú³õʼ»¯ */
  LCD_GPIOInit();
        
  LCD_DisplayOff();
        
  /* ʹÄÜLCDʱÖÓ */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE);
        
  /* ʹÄÜDMAʧ×Ù*/
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE);
        
  /* ˮƽͬ²½ÐźÅ---µÍµçƽÓÐЧ */
  LTDC_InitStruct.LTDC_HSPolarity = LTDC_HSPolarity_AL;   

  /* ´¹Ö±Í¬²½ÐźÅ---µÍµçƽÓÐЧ */  
  LTDC_InitStruct.LTDC_VSPolarity = LTDC_VSPolarity_AL;  
        
  /* Êý¾ÝʹÄÜÐźÅ---µÍµçƽÓÐЧ */
  LTDC_InitStruct.LTDC_DEPolarity = LTDC_DEPolarity_AL;   

  /* ÏñËØʱÖÓÅäÖÃ--- */
  LTDC_InitStruct.LTDC_PCPolarity = LTDC_PCPolarity_IPC;
        
        /* LCD±³¹âÉèÖà */
  LTDC_InitStruct.LTDC_BackgroundRedValue = 0;            
  LTDC_InitStruct.LTDC_BackgroundGreenValue = 0;         
  LTDC_InitStruct.LTDC_BackgroundBlueValue = 0;         
  /*
   ****************************************************************************
   *PLLSAI_VCO = HSE*PLLSAI_N / PLL_M = 8 * 192 / 8 = 192MHz
   *PLLLCDCLK = PLLSAI_VCO / PLLSAI_R = 192 / 3 = 64 Mhz
   *LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = 64 / 8 = 8 Mhz
   ****************************************************************************
   */
  RCC_PLLSAIConfig(250, 2, 8);//RCC_PLLSAIConfig(192, 7, 4);
  RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div4);        
        
  /* ʹÄÜPLLSAIʱÖÓ */
  RCC_PLLSAICmd(ENABLE);
        
  /* µÈ´ýPLLSAIʱÖÓ */
  while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET){}
        
//-- timing configuration --//
//-- Configure horizontal synchronization width --//                  
  /*  */
  LTDC_InitStruct.LTDC_HorizontalSync = HSYNC;
  /*  */
  LTDC_InitStruct.LTDC_VerticalSync = VSYNC;
  /*  */
  LTDC_InitStruct.LTDC_AccumulatedHBP = HBP;
  /*  */
  LTDC_InitStruct.LTDC_AccumulatedVBP = VBP;  
  /*  */
  LTDC_InitStruct.LTDC_AccumulatedActiveW = LCDX + HBP;
  /*  */
  LTDC_InitStruct.LTDC_AccumulatedActiveH = LCDY + VBP;
  /*  */
  LTDC_InitStruct.LTDC_TotalWidth = LCDX + HBP + HFP;
  /*  */
  LTDC_InitStruct.LTDC_TotalHeigh = LCDY + VBP + VFP;

  LTDC_Init(<DC_InitStruct);
               
  LTDC_Layer_InitStruct.LTDC_HorizontalStart = HBP+1;
  LTDC_Layer_InitStruct.LTDC_HorizontalStop = (LCDX + HBP);
  LTDC_Layer_InitStruct.LTDC_VerticalStart = VBP+1;
  LTDC_Layer_InitStruct.LTDC_VerticalStop = (LCDY + VBP);        

  /* Pixel Format configuration*/            
  LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB888;
  /* 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 = 0x0000ff;        
  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 = ((LCDX * 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 = (LCDX * 2);
  /* configure the number of lines */  
  LTDC_Layer_InitStruct.LTDC_CFBLineNumber = LCDY;

  /* Input Address configuration */   
  LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER;

  LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct);

  /* Configure Layer2 */
  LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER + BUFFER_OFFSET;
  LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA;   
  LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA;
  LTDC_LayerInit(LTDC_Layer2, <DC_Layer_InitStruct);
        
  LTDC_ReloadConfig(LTDC_IMReload);

  /* Enable foreground & background Layers */
  LTDC_LayerCmd(LTDC_Layer1, ENABLE);
//  LTDC_LayerCmd(LTDC_Layer2, ENABLE);
  LTDC_ReloadConfig(LTDC_IMReload);
        
  LCD_DisplayOn();


试过驱动800 X480的TFT,写数据只显示到320行,驱动800 X 600 的TFT数据像是到400行,请问是什么问题???????????????,用SDROM做内存显示


友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。