2020-02-23 06:27 AM
Hello!
I have problem.
Important - this problem occurs not only whenI use TOuchGFX. This problem uccurs then I init LTDC and try to draw rectangles with DMA2D using simple functions, without any libraries
This probleb is only when I use RGB888
I try tp draw blue rectangle an I get color stripes - red at right and at green at the left sides of pictures or rectangles.
The appearance of artifacts depends on the coordinates of the beginning and end of the lines.
If end coordinate of line is even - no artifact. If end coordinate of line is odd - green stripe
If begin coordinate is 0 and 1, or 4 and 5, or 8 and 9 - there is no artifacts
If begin coordinate is 2 and 3, or 6 and 7, or 1 and 1 - I get red stripe at the left side
For better understanding:
I use STM32F746, 32-bit SDRAM, CubeMX 5.6, Keil 5, HAL Library
THis is code of DMA2D init
static void MX_DMA2D_Init(void)
{
hdma2d.Instance = DMA2D;
hdma2d.Init.Mode = DMA2D_M2M;
hdma2d.Init.ColorMode = DMA2D_OUTPUT_RGB888;
hdma2d.Init.OutputOffset = 0;
hdma2d.LayerCfg[0].InputOffset = 0;
hdma2d.LayerCfg[0].InputColorMode = DMA2D_INPUT_RGB888;
hdma2d.LayerCfg[0].AlphaMode = DMA2D_NO_MODIF_ALPHA;
hdma2d.LayerCfg[0].InputAlpha = 0;
if (HAL_DMA2D_Init(&hdma2d) != HAL_OK)
{
Error_Handler();
}
if (HAL_DMA2D_ConfigLayer(&hdma2d, 0) != HAL_OK)
{
Error_Handler();
}
}
THis is code of LTDC layer init
pLayerCfg.WindowX0 = 0;
pLayerCfg.WindowX1 = 1024;
pLayerCfg.WindowY0 = 0;
pLayerCfg.WindowY1 = 600;
pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB888;
pLayerCfg.Alpha = 255;
pLayerCfg.Alpha0 = 0;
pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
pLayerCfg.FBStartAdress = 0xD0000000;
pLayerCfg.ImageWidth = 1024;
pLayerCfg.ImageHeight = 600;
pLayerCfg.Backcolor.Blue = 0;
pLayerCfg.Backcolor.Green = 0;
pLayerCfg.Backcolor.Red = 0;
if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK)
{
Error_Handler();
}
This is code of rectangle drawing
void TFT_FillRectangle(uint16_t x1, uint16_t y1,
uint16_t x2, uint16_t y2, uint32_t color)
{
if(x1>x2) swap(x1,x2);
if(y1>y2) swap(y1,y2);
uint32_t addr=0;
addr = hltdc.LayerCfg[0].FBStartAdress + 3*(y1*hltdc.LayerCfg[0].ImageWidth+x1);
hdma2d.Init.Mode = DMA2D_R2M;
hdma2d.Init.OutputOffset = hltdc.LayerCfg[0].ImageWidth - (x2-x1);
if(HAL_DMA2D_Init(&hdma2d) == HAL_OK)
{
if(HAL_DMA2D_Start(&hdma2d, color, addr, x2-x1, y2-y1) == HAL_OK)
{
HAL_DMA2D_PollForTransfer(&hdma2d, 10);
}
}
}
Help me please