里飞网
标题:
LTDC—驱动RGB TFT屏显示
[打印本页]
作者:
阿里兄
时间:
2019-12-20 15:07
标题:
LTDC—驱动RGB TFT屏显示
LTDC—驱动RGB TFT屏显示
一些注意事项,后面直接看代码
1、STM32F750Z8在使用了SDRAM后,最多只能驱动RGB666。
2、LCD有闪烁,可适当提高LTDC时钟频率,如果LTDC时钟过高,则LCD可能花屏。
3、LTDC比较好配置,直接从手删除拿来参数填上即可。
4、LTDC显示需要用到SDRAM,SDRAM需在LTDC前初始化好。
LTDC初始化
void MX_LTDC_Init(void)
{
LTDC_LayerCfgTypeDef pLayerCfg = {0};
hltdc.Instance = LTDC;
hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;
hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL;
hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
hltdc.Init.HorizontalSync = 19;
hltdc.Init.VerticalSync = 9;
hltdc.Init.AccumulatedHBP = 65;
hltdc.Init.AccumulatedVBP = 32;
hltdc.Init.AccumulatedActiveW = 865;
hltdc.Init.AccumulatedActiveH = 512;
hltdc.Init.TotalWidth = 881;
hltdc.Init.TotalHeigh = 519;
hltdc.Init.Backcolor.Blue = 0;
hltdc.Init.Backcolor.Green = 0;
hltdc.Init.Backcolor.Red = 0;
if (HAL_LTDC_Init(&hltdc) != HAL_OK)
{
Error_Handler();
}
pLayerCfg.WindowX0 = 0;
pLayerCfg.WindowX1 = 800;
pLayerCfg.WindowY0 = 0;
pLayerCfg.WindowY1 = 480;
pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
pLayerCfg.Alpha = 255;
pLayerCfg.Alpha0 = 0;
pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
pLayerCfg.FBStartAdress = 0xC0000000;
pLayerCfg.ImageWidth = 800;
pLayerCfg.ImageHeight = 480;
pLayerCfg.Backcolor.Blue = 0;
pLayerCfg.Backcolor.Green = 0;
pLayerCfg.Backcolor.Red = 0;
if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK)
{
Error_Handler();
}
}
复制代码
LTDC刷屏测试
uint32_t tft_vram[480][800] __attribute__((at(0xC0000000)));
void LTDC_Clear(uint32_t color)
{
for ( int y = 0 ; y < 480 ; y++ )
{
for ( int x = 0 ; x < 800 ; x++ )
{
tft_vram[y][x] = color;
}
}
}
void LTDC_Test(void)
{
uint32_t color;
while ( 1 )
{
HAL_Delay(2000);
color = rand();
//printf("color:%x\r\n",color);
LTDC_Clear(color);
}
}
复制代码
CUBEMX配置
(, 下载次数: 1196)
上传
点击文件名下载附件
(, 下载次数: 1212)
上传
点击文件名下载附件
工程代码:
(, 下载次数: 1607)
上传
点击文件名下载附件
欢迎光临 里飞网 (http://dz.lfly.xyz/)
Powered by Discuz! X3.3