STM32F429驱动7寸屏

2019-07-21 00:47发布

最近在stm32f429 discover板上驱动7寸屏(800X480),stm32f429内部带屏的驱动器LTDC,之前在r板上运行网上的emwin很正常,但是屏幕是2.4寸的,现在改为7寸屏,可以显示但是显示的尺寸跟分辨率不对,我的相关配置如下,这个问题让我纠结好久了,希望知道的大大给我指点一下,不胜感激,必有重谢!
另附图片 [mw_shl_code=c,true]#define LCD_PIXEL_WIDTH ((uint16_t)800) #define LCD_PIXEL_HEIGHT ((uint16_t)480) #define HSW ((uint16_t)48) /* Horizontal synchronization */ #define HBP ((uint16_t)40) /* Horizontal back porch */ #define HFP ((uint16_t)40) /* Horizontal front porch */ #define VSW ((uint16_t)3) /* Vertical synchronization */ #define VBP ((uint16_t)29) /* Vertical back porch */ #define VFP ((uint16_t)13) /* Vertical front porch */ #define HSTART (HBP) #define HSTOP (LCD_PIXEL_WIDTH+HSTART) #define VSTART (VBP) #define VSTOP (LCD_PIXEL_HEIGHT+VSTART) #define LCD_FRAME_BUFFER ((uint32_t)0xD0000000) //LCD?????????×???·?????·SDRAM #define BUFFER_OFFSET ((uint32_t)0x60000) void LCD_Init(void)函数中: RCC_PLLSAIConfig(192, 7, 4); RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div2);//RCC_PLLSAIDivR_Div8 /* 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 = HSW-1; /* Configure vertical synchronization height */ LTDC_InitStruct.LTDC_VerticalSync = VSW-1; /* Configure accumulated horizontal back porch */ LTDC_InitStruct.LTDC_AccumulatedHBP = HBP-1; /* Configure accumulated vertical back porch */ LTDC_InitStruct.LTDC_AccumulatedVBP = VBP-1; /* Configure accumulated active width */ LTDC_InitStruct.LTDC_AccumulatedActiveW = LCD_PIXEL_WIDTH + HBP-1; /* Configure accumulated active height */ LTDC_InitStruct.LTDC_AccumulatedActiveH = LCD_PIXEL_HEIGHT + VBP-1; /* Configure total width */ LTDC_InitStruct.LTDC_TotalWidth = LCD_PIXEL_WIDTH + HBP + HFP-1; /* Configure total height */ LTDC_InitStruct.LTDC_TotalHeigh = LCD_PIXEL_HEIGHT + VBP + VFP-1; LTDC_Init(&LTDC_InitStruct); static void _LCD_InitController(int LayerIndex) 函数中: xSize = LCD_GetXSizeEx(LayerIndex); ySize = LCD_GetYSizeEx(LayerIndex); LTDC_Layer_InitStruct.LTDC_HorizontalStart = HSTART; LTDC_Layer_InitStruct.LTDC_HorizontalStop = (xSize + HSTART-1); LTDC_Layer_InitStruct.LTDC_VerticalStart = VSTART; LTDC_Layer_InitStruct.LTDC_VerticalStop = (ySize + VSTART-1);[/mw_shl_code] [mw_shl_code=c,true] [/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
18条回答
rgzdb
1楼-- · 2019-07-21 16:23
void LCD_Init(void)
{
  LTDC_InitTypeDef       LTDC_InitStruct;
  LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct;
  LTDC_Layer_TypeDef     LTDC_Layerx;
  

  /* 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_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 / LL_M = 8 * 192 / 8 = 192MHz
   *PLLLCDCLK = LLSAI_VCO / LLSAI_R = 192 / 3 = 64 Mhz
   *LTDC clock frequency = LLLCDCLK / RCC_PLLSAIDivR = 64 / 2 = 32 Mhz
   ****************************************************************************
   */
  RCC_PLLSAIConfig(192, 7, 3);
  RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div4);
  /* 使能PLLSAI时钟 */
  RCC_PLLSAICmd(ENABLE);
  /* 等待PLLSAI时钟 */
  while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET){}



  /* Configure horizontal synchronization width */     
  LTDC_InitStruct.LTDC_HorizontalSync = 39;
  /* Configure vertical synchronization height */
  LTDC_InitStruct.LTDC_VerticalSync = 19;
  /* Configure accumulated horizontal back porch */
  LTDC_InitStruct.LTDC_AccumulatedHBP = 45; 
  /* Configure accumulated vertical back porch */
  LTDC_InitStruct.LTDC_AccumulatedVBP = 22;  
  /* Configure accumulated active width */  
  LTDC_InitStruct.LTDC_AccumulatedActiveW = 845;
  /* Configure accumulated active height */
  LTDC_InitStruct.LTDC_AccumulatedActiveH = 502;
  /* Configure total width */
  LTDC_InitStruct.LTDC_TotalWidth = 1055; 
  /* Configure total height */
  LTDC_InitStruct.LTDC_TotalHeigh = 524;

  LTDC_Init(<DC_InitStruct);

  LTDC_ITConfig(LTDC_IER_LIE,ENABLE);  
NVIC_SetPriority(LTDC_IRQn,0);
  NVIC_EnableIRQ(LTDC_IRQn);

   DMA2D_ITConfig(DMA2D_CR_TCIE,ENABLE);
   NVIC_SetPriority(DMA2D_IRQn,0);
   NVIC_EnableIRQ(DMA2D_IRQn);
   DMA2D->IFCR=(u32)DMA2D_IFSR_CTCIF;
  
  
   

 LTDC_Layer_InitStruct.LTDC_HorizontalStart = 46;  //46
// LTDC_Layer_InitStruct.LTDC_HorizontalStart = 70;
 // LTDC_Layer_InitStruct.LTDC_HorizontalStop = (480 + 43 - 1); 
  LTDC_Layer_InitStruct.LTDC_HorizontalStop = (800 + 46 - 1); 
 
  LTDC_Layer_InitStruct.LTDC_VarticalStart = 23;//23
 // LTDC_Layer_InitStruct.LTDC_VerticalStop = (272 + 12 - 1);
  LTDC_Layer_InitStruct.LTDC_VerticalStop = (480 + 23 - 1);
  /* ixel 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 = ((480 * 2) + 3);
 LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((800 * 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:
      itch = Active high width x number of bytes per pixel     
  */ 
 // LTDC_Layer_InitStruct.LTDC_CFBPitch = (480 * 2);
LTDC_Layer_InitStruct.LTDC_CFBPitch = (800 * 2);
  /* configure the number of lines */  
 // LTDC_Layer_InitStruct.LTDC_CFBLineNumber = 272;
LTDC_Layer_InitStruct.LTDC_CFBLineNumber = 480;
  /* 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();
}
hukee
2楼-- · 2019-07-21 19:29
f429+sdram+tn92  从某学习板的4.3改过来的 一直没去用 只是测试了下 目测比较乱 呵
simms01
3楼-- · 2019-07-21 21:39
回复【6楼】rgzdb:
---------------------------------
转接模拟屏啊
simms01
4楼-- · 2019-07-21 23:21
回复【10楼】maodewen:
---------------------------------
不加sdram,将屏幕清为一种颜 {MOD}行不行呢,手头上只有f429zg核心板+7寸屏
maodewen
5楼-- · 2019-07-22 04:29
 精彩回答 2  元偷偷看……
麦田稻草
6楼-- · 2019-07-22 05:31
回复【11楼】maodewen:
---------------------------------
DMA2D 24位 {MOD}部分怎么驱动的?

一周热门 更多>