大家好,年底了发一个问题贴,希望过了春节能得到大家帮助.STM32F429驱动VGA显示器,显示器显示输入不支持,使用的驱动芯片为ADV7123!! 一样的程序,直接带7寸屏是OK的,能正常显示.
分辨率为800*600,驱动代码如下:
/**
* @brief LTDC MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - Peripheral's GPIO Configuration
* @param hltdc: LTDC handle pointer
* @retval None
*/
void HAL_LTDC_MspInit(LTDC_HandleTypeDef *hltdc)
{
GPIO_InitTypeDef GPIO_Init_Structure;
/* Enable peripherals and GPIO Clocks */
/* Enable the LTDC Clock */
__LTDC_CLK_ENABLE();
/* Enable GPIOs clock */
__GPIOE_CLK_ENABLE();
__GPIOF_CLK_ENABLE();
__GPIOG_CLK_ENABLE();
__GPIOH_CLK_ENABLE();
__GPIOI_CLK_ENABLE();
// LCD_BL_ON();
/* Configure peripheral GPIO */
/* LTDC pins configuraiton: PE4,5,6 */
GPIO_Init_Structure.Pin = GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6;
GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP;
GPIO_Init_Structure.Pull = GPIO_NOPULL;
GPIO_Init_Structure.Speed = GPIO_SPEED_FAST;
GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC;
HAL_GPIO_Init(GPIOE, &GPIO_Init_Structure);
/* LTDC pins configuraiton: PF10原来是LCD_DE,现在改为BLANK N */
GPIO_Init_Structure.Pin = GPIO_PIN_10;
GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP;
GPIO_Init_Structure.Pull = GPIO_NOPULL;
GPIO_Init_Structure.Speed = GPIO_SPEED_FAST;
GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC;
HAL_GPIO_Init(GPIOF, &GPIO_Init_Structure);
/* LTDC pins configuraiton: PG6,7,10,11,12 */
GPIO_Init_Structure.Pin = GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12;
GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP;
GPIO_Init_Structure.Pull = GPIO_NOPULL;
GPIO_Init_Structure.Speed = GPIO_SPEED_FAST;
GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC;
HAL_GPIO_Init(GPIOG, &GPIO_Init_Structure);
/* LTDC pins configuraiton: PH2,3,8,9,10,11,12,13,14,15 */
GPIO_Init_Structure.Pin = GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_8 | GPIO_PIN_9 | \
GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 |\
GPIO_PIN_14 | GPIO_PIN_15;
GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP;
GPIO_Init_Structure.Pull = GPIO_NOPULL;
GPIO_Init_Structure.Speed = GPIO_SPEED_FAST;
GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC;
HAL_GPIO_Init(GPIOH, &GPIO_Init_Structure);
/* LTDC pins configuraiton: PI0,1,2,4,5,6,7,8,9,10 */
GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_4 | \
GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 |\
GPIO_PIN_9 | GPIO_PIN_10;
GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP;
GPIO_Init_Structure.Pull = GPIO_NOPULL;
GPIO_Init_Structure.Speed = GPIO_SPEED_FAST;
GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC;
HAL_GPIO_Init(GPIOI, &GPIO_Init_Structure);
/* Set LTDC Interrupt to the lowest priority */
HAL_NVIC_SetPriority(LTDC_IRQn, 0xF, 0);
/* Enable LTDC Interrupt */
HAL_NVIC_EnableIRQ(LTDC_IRQn);
}
#define HSW ((uint16_t)40) /* Horizontal synchronization */
#define HBP ((uint16_t)46) /* Horizontal back porch */
#define HFP ((uint16_t)21) /* Horizontal front porch */
#define VSW ((uint16_t)40) /* Vertical synchronization */
#define VBP ((uint16_t)24) /* Vertical back porch */
#define VFP ((uint16_t)22) /* Vertical front porch */
#define HSTART (HBP)
#define HSTOP (XSIZE_PHYS+HSTART)
#define VSTART (VBP)
#define VSTOP (YSIZE_PHYS+VSTART)
static void LCD_LL_Init(void)
{
static RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
/* DeInit */
HAL_LTDC_DeInit(&hltdc);
/* Set LCD Timings */
hltdc.Init.HorizontalSync = HSW-1;//40;
hltdc.Init.VerticalSync = VSW-1;//9;
hltdc.Init.AccumulatedHBP = HBP-1;//Horizontal back porch;
hltdc.Init.AccumulatedVBP = VBP-1;//Vertical back porch
hltdc.Init.AccumulatedActiveH = YSIZE_PHYS+VBP-1;//502;
hltdc.Init.AccumulatedActiveW = XSIZE_PHYS+HBP-1;//845;
hltdc.Init.TotalHeigh = YSIZE_PHYS+VBP+VFP-1;//525;
hltdc.Init.TotalWidth = 1056;//XSIZE_PHYS+HBP+HFP-1;//1056;
/* background value */
hltdc.Init.Backcolor.Blue = 0;
hltdc.Init.Backcolor.Green = 0;
hltdc.Init.Backcolor.Red = 0;
/* LCD clock configuration */
/* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
/* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 368 Mhz */
/* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 368/4 = 80 Mhz */
/* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_4 = 80/2 = 40 Mhz */
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
PeriphClkInitStruct.PLLSAI.PLLSAIN = 160;
PeriphClkInitStruct.PLLSAI.PLLSAIR = 2;
PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_4;
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
/* Polarity */
hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;
hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
hltdc.Init.DEPolarity = LTDC_VSPOLARITY_AL;
hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
hltdc.Instance = LTDC;
HAL_LTDC_Init(&hltdc);
HAL_LTDC_ProgramLineEvent(&hltdc, 0);
/* Configure the DMA2D default mode */
hdma2d.Init.Mode = DMA2D_R2M;
hdma2d.Init.ColorMode = DMA2D_RGB565;
hdma2d.Init.OutputOffset = 0x0;
hdma2d.Instance = DMA2D;
if(HAL_DMA2D_Init(&hdma2d) != HAL_OK)
{
while (1);
}
}
|
|