你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

LTDC驱动遇到问题,求助

[复制链接]
wofei1314 提问时间:2016-1-28 12:08 /
LTDC的层初始化代码
  1. void f_LTDC_LayerInit(uint8_t LayerIndex)
  2. {
  3.     LTDC_Layer_InitTypeDef LTDC_Layer_Init;
  4. //    LTDC_CLUT_InitTypeDef  LTDC_CLUT_InitStruct;
  5.      
  6.     LTDC_Layer_Init.LTDC_HorizontalStart = TFT_HBP ;
  7.     LTDC_Layer_Init.LTDC_HorizontalStop = TFT_PHYW + TFT_HBP -1;
  8.     LTDC_Layer_Init.LTDC_VerticalStart = TFT_VBP ;
  9.     LTDC_Layer_Init.LTDC_VerticalStop = TFT_PHYH + TFT_VBP -1;
  10.     LTDC_Layer_Init.LTDC_PixelFormat = LTDC_Pixelformat_RGB565;
  11.     LTDC_Layer_Init.LTDC_ConstantAlpha = 255;
  12.     LTDC_Layer_Init.LTDC_DefaultColorBlue = 0;        
  13.     LTDC_Layer_Init.LTDC_DefaultColorGreen = 0;      
  14.     LTDC_Layer_Init.LTDC_DefaultColorRed = 0;         
  15.     LTDC_Layer_Init.LTDC_DefaultColorAlpha = 0;
  16.     LTDC_Layer_Init.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA;   
  17.     LTDC_Layer_Init.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_CA;
  18.    
  19.     /* the length of one line of pixels in bytes + 3 then :
  20.     5.Line Lenth = Active high width x number of bytes per pixel + 3  
  21.     6.Active high width         = 240  
  22.     7.number of bytes per pixel = 2    (pixel_format : RGB565)  
  23.     8.*/
  24.     LTDC_Layer_Init.LTDC_CFBLineLength = (TFT_PHYW*2) +3;//old=3 //1224
  25.     /*  the pitch is the increment from the start of one line of pixels to the  
  26.     12.start of the next line in bytes, then :
  27.     13.Pitch = Active high width x number of bytes per pixel      
  28.     14.*/
  29.     LTDC_Layer_Init.LTDC_CFBPitch = TFT_PHYW*2;
  30.     /* configure the number of lines */
  31.     LTDC_Layer_Init.LTDC_CFBLineNumber = TFT_PHYH;
  32.     /* Input Address configuration */
  33.     LTDC_Layer_Init.LTDC_CFBStartAdress = SDRAM_BASE;
  34.   
  35.     LTDC_LayerInit((LayerIndex == 0 ? LTDC_Layer1 : LTDC_Layer2), <DC_Layer_Init);
  36.   
  37. //  /*  Enable LUT on demand */
  38. //  BitsPerPixel = LCD_GetBitsPerPixelEx(LayerIndex);
  39. //  if (BitsPerPixel <= 8)
  40. //  {
  41. //    /* Enable usage of LUT for all modes with <= 8bpp */
  42. //    LTDC_CLUTCmd((LayerIndex == 0 ? LTDC_Layer1 : LTDC_Layer2), ENABLE);
  43. //  }
  44. //  else
  45. //  {
  46. //    /*  Optional CLUT initialization for AL88 mode (16bpp) */
  47. //    if (apColorConvAPI[LayerIndex] == GUICC_88666I)
  48. //    {
  49. //      LTDC_CLUTCmd((LayerIndex == 0 ? LTDC_Layer1 : LTDC_Layer2), ENABLE);
  50. //      for (i = 0; i < 256; i++)
  51. //      {
  52. //        Color = LCD_API_ColorConv_8666.pfIndex2Color(i);
  53. //        LTDC_CLUT_InitStruct.LTDC_BlueValue   =  ((Color >> 16) & 0xff);
  54. //        LTDC_CLUT_InitStruct.LTDC_GreenValue  =  ((Color >>  8) & 0xff);
  55. //        LTDC_CLUT_InitStruct.LTDC_RedValue    =   (Color        & 0xff);
  56. //        LTDC_CLUT_InitStruct.LTDC_CLUTAdress  =  i << 24;
  57. //        LTDC_CLUTInit((LayerIndex == 0 ? LTDC_Layer1 : LTDC_Layer2), <DC_CLUT_InitStruct);
  58. //      }
  59. //    }
  60. //  }
  61.   
  62.   /*  Enable layer */
  63.   LTDC_LayerCmd((LayerIndex == 0 ? LTDC_Layer1 : LTDC_Layer2), ENABLE);
  64.   
  65.   /* Reload configuration */
  66.   LTDC_ReloadConfig(LTDC_VBReload);
  67.   
  68.   /* dithering activation */
  69.   //LTDC_DitherCmd(ENABLE);
  70.   //LTDC_ReloadConfig(LTDC_IMReload);
  71.   LTDC_Cmd(ENABLE);
  72. }
复制代码

KD070C-4-CTP-002 SPEC V1.1(柯达).pdf

下载

1.24 MB, 下载次数: 18, 下载积分: ST金币 -1

液晶屏数据手册

收藏 1 评论3 发布时间:2016-1-28 12:08

举报

3个回答
wofei1314 回答时间:2016-1-28 12:10:21
  1. static void LCD_AF_GPIOConfig(void)
  2. {
  3.   GPIO_InitTypeDef GPIO_InitStruct;
  4.   
  5.   /* Enable GPIOI, GPIOJ, GPIOK AHB Clocks */
  6.   RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_GPIOG | \
  7.                          RCC_AHB1Periph_GPIOH | RCC_AHB1Periph_GPIOI ,  ENABLE);

  8. /* GPIOs Configuration */
  9. /*
  10. +------------------------+-----------------------+----------------------------+
  11. +                       LCD pins assignment                                   +
  12. +------------------------+-----------------------+----------------------------+
  13. |                        |                       |                            |
  14. |                        |                       |                            |
  15. |                        |  LCD_TFT G2 <-> PA.06 |                            |
  16. |  LCD_TFT R3 <-> PB.00  |  LCD_TFT G3 <-> PG.10 |  LCD_TFT B3 <-> PG.11      |
  17. |  LCD_TFT R4 <-> PA.11  |  LCD_TFT G4 <-> PB.10 |  LCD_TFT B4 <-> PG.12      |
  18. |  LCD_TFT R5 <-> PA.12  |  LCD_TFT G5 <-> PB.11 |  LCD_TFT B5 <-> PA.03      |
  19. |  LCD_TFT R6 <-> PB.01  |  LCD_TFT G6 <-> PC.07 |  LCD_TFT B6 <-> PB.08      |
  20. |  LCD_TFT R7 <-> PG.06  |  LCD_TFT G7 <-> PD.03 |  LCD_TFT B7 <-> PB.09      |
  21. -------------------------------------------------------------------------------
  22.           |  LCD_TFT HSYNC <-> PC.06  | LCDTFT VSYNC <->  PA.04 |
  23.           |  LCD_TFT CLK   <-> PG.07  | LCD_TFT DE   <->  PF.10 |
  24.            -----------------------------------------------------
  25. */

  26. /* GPIOI configuration */
  27.   //GPIO A
  28.     GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_LTDC);
  29.     GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_LTDC);
  30.     GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_LTDC);
  31.     GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_LTDC);
  32.     GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_LTDC);
  33.    
  34.     GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_3 | GPIO_Pin_6 | GPIO_Pin_11 | GPIO_Pin_12;

  35.     GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
  36.     GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
  37.     GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
  38.     GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
  39.     GPIO_Init(GPIOA, &GPIO_InitStruct);

  40.     //GPIO C
  41.     GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_LTDC);
  42.     GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_LTDC);
  43.    
  44.     GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;

  45.     GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
  46.     GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
  47.     GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
  48.     GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
  49.     GPIO_Init(GPIOC, &GPIO_InitStruct);
  50.    
  51.     //GPIO F
  52.     GPIO_PinAFConfig(GPIOF, GPIO_PinSource10, GPIO_AF_LTDC);
  53.     GPIO_InitStruct.GPIO_Pin = GPIO_Pin_10;

  54.     GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
  55.     GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
  56.     GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
  57.     GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
  58.     GPIO_Init(GPIOF, &GPIO_InitStruct);

  59.     //GPIO G
  60.     GPIO_PinAFConfig(GPIOG, GPIO_PinSource6, GPIO_AF_LTDC);
  61.     GPIO_PinAFConfig(GPIOG, GPIO_PinSource7, GPIO_AF_LTDC);
  62.     GPIO_PinAFConfig(GPIOG, GPIO_PinSource10, GPIO_AF_LTDC);
  63.     GPIO_PinAFConfig(GPIOG, GPIO_PinSource11, GPIO_AF_LTDC);
  64.     GPIO_PinAFConfig(GPIOG, GPIO_PinSource12, GPIO_AF_LTDC);
  65.     GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12;

  66.     GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
  67.     GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
  68.     GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
  69.     GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
  70.     GPIO_Init(GPIOG, &GPIO_InitStruct);
  71.        
  72.         //GPIO B
  73.         GPIO_PinAFConfig(GPIOB, GPIO_PinSource0, GPIO_AF_LTDC);
  74.         GPIO_PinAFConfig(GPIOB, GPIO_PinSource1, GPIO_AF_LTDC);
  75.     GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_LTDC);
  76.         GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_LTDC);
  77.         GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_LTDC);
  78.         GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_LTDC);

  79.         GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11;
  80.        
  81.     GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
  82.     GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
  83.     GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
  84.     GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
  85.     GPIO_Init(GPIOB, &GPIO_InitStruct);
  86.        
  87.     //GPIO D
  88.     GPIO_PinAFConfig(GPIOD, GPIO_PinSource3, GPIO_AF_LTDC);


  89.     GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3 ;
  90.                              
  91.     GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
  92.     GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
  93.     GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
  94.     GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
  95.     GPIO_Init(GPIOD, &GPIO_InitStruct);
  96. }
复制代码
wofei1314 回答时间:2016-1-28 12:10:38
  1. void f_LTDC_Init(void)
  2. {
  3.     LTDC_InitTypeDef       LTDC_InitStruct;
  4.    
  5.      /* Enable the LTDC Clock */
  6.     RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE);
  7.    
  8.     /* Configure PLLSAI prescalers for LCD */                       
  9. //    RCC_PLLSAIConfig(200, 4, 3);        //OK pclk run in 23MHz
  10. //    RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div4);//0127,old=2分频
  11.     //以下两行是野火的程序中的配置
  12.     RCC_PLLSAIConfig(200, 4, 3);
  13.     RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div2);
  14.    
  15.     /* Enable PLLSAI Clock */
  16.     RCC_PLLSAICmd(ENABLE);
  17.     /* Wait for PLLSAI activation */
  18.     while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET)
  19.     {
  20.     }
  21.    
  22.    
  23.     /* Enable the DMA2D Clock */
  24.     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE);
  25.    
  26.     /* Configure the LCD Control pins */
  27.     LCD_AF_GPIOConfig();  
  28.                
  29.     /* Polarity configuration */
  30.     /* Initialize the horizontal synchronization polarity as active low */
  31.     LTDC_InitStruct.LTDC_HSPolarity = LTDC_HSPolarity_AL;     
  32.     /* Initialize the vertical synchronization polarity as active low */  
  33.     LTDC_InitStruct.LTDC_VSPolarity = LTDC_VSPolarity_AL;     
  34.     /* Initialize the data enable polarity as active low */
  35.     LTDC_InitStruct.LTDC_DEPolarity = LTDC_DEPolarity_AL;     
  36.     /* Initialize the pixel clock polarity as input pixel clock */
  37.     LTDC_InitStruct.LTDC_PCPolarity = LTDC_PCPolarity_IPC;
  38.    
  39.     /* Configure R,G,B component values for LCD background color */                  
  40.     LTDC_InitStruct.LTDC_BackgroundRedValue = 255;            
  41.     LTDC_InitStruct.LTDC_BackgroundGreenValue = 0;         
  42.     LTDC_InitStruct.LTDC_BackgroundBlueValue = 0;  
  43.      
  44.     LTDC_InitStruct.LTDC_HorizontalSync = TFT_HSW-1;
  45.     /* Configure vertical synchronization height */
  46.     LTDC_InitStruct.LTDC_VerticalSync = TFT_VSW-1;
  47.     /* Configure accumulated horizontal back porch */
  48.     LTDC_InitStruct.LTDC_AccumulatedHBP = TFT_HBP-1;
  49.     /* Configure accumulated vertical back porch */
  50.     LTDC_InitStruct.LTDC_AccumulatedVBP = TFT_VBP-1;  
  51.     /* Configure accumulated active width */  
  52.     LTDC_InitStruct.LTDC_AccumulatedActiveW = TFT_PHYW + TFT_HBP -1;  //old后-1,845
  53.     /* Configure accumulated active height */                     
  54.     LTDC_InitStruct.LTDC_AccumulatedActiveH = TFT_PHYH + TFT_VBP -1;  //old后-1
  55.     /* Configure total width */
  56.     LTDC_InitStruct.LTDC_TotalWidth = TFT_PHYW + TFT_HBP + TFT_HFP -1;
  57.     /* Configure total height */
  58.     LTDC_InitStruct.LTDC_TotalHeigh = TFT_PHYH + TFT_VBP + TFT_VFP -1;
  59.    
  60.     LTDC_Init(&LTDC_InitStruct);
  61.    
  62. //    LTDC_ITConfig(LTDC_IT_LI, ENABLE);
  63. //    NVIC_SetPriority(LTDC_IRQn, 0);
  64. //    NVIC_EnableIRQ(LTDC_IRQn);
  65. }
复制代码
xmshao 回答时间:2016-1-29 17:54:43
除了代码还是代码

所属标签

相似问题

关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版