cancel
Showing results for 
Search instead for 
Did you mean: 

Filling Buffer with DMA2D in L8 color format draws one and skips one pixel.

chaari
Associate II

Hello community,

I am using NUCELOH7A3 and a 800x320 display. I could fill the screen, display lines and texts using RGB565 and ARGB8888. Now I wanted to use the L8 forrmat with a LUT.

Using the the DMA2D mode Memory to Memory works fine (array)! But using the mode Register to Memory does not.

BSP_LCD_WritePixel() works fine with the L8 format. But the BSP_LCD_FillRect() that uses DMA2D has some problems.

It displays verticle lines, displaying 1 line and skipping 1 line after. So it writes the pixel and skips the one after.

chaari_0-1707739768226.jpegchaari_1-1707740041801.jpeg

 

Here is the code.

 

int32_t BSP_LCD_FillRect(uint32_t Instance, uint32_t Xpos, uint32_t Ypos, uint32_t Width, uint32_t Height, uint32_t Color)
{
  uint32_t  Xaddress;

  /* Get the rectangle start address */
  Xaddress = (hlcd_ltdc.LayerCfg[Lcd_Ctx[Instance].ActiveLayer].FBStartAdress) + (Lcd_Ctx[Instance].BppFactor*((Lcd_Ctx[Instance].XSize*Ypos) + Xpos));

  /* Fill the rectangle */
  LL_FillBuffer(Instance, (uint32_t *)Xaddress, Width, Height, (Lcd_Ctx[Instance].XSize - Width), Color);
  return BSP_ERROR_NONE;
}

 

 

static void LL_FillBuffer(uint32_t Instance, uint32_t *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t Color)
{
  uint32_t output_color_mode, input_color = Color;

  switch(Lcd_Ctx[Instance].PixelFormat)
  {
  case LCD_PIXEL_FORMAT_RGB565:
    output_color_mode = DMA2D_OUTPUT_RGB565; /* RGB565 */
    input_color = CONVERTRGB5652ARGB8888(Color);
    break;
  case LCD_PIXEL_FORMAT_L8:
      output_color_mode = DMA2D_OUTPUT_ARGB8888; /* RGB565 */
      hlcd_dma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_L8;
      break;
  case LCD_PIXEL_FORMAT_RGB888:
  default:
    output_color_mode = DMA2D_OUTPUT_ARGB8888; /* ARGB8888 */
    break;
  }

  /* Register to memory mode with ARGB8888 as color Mode */
  hlcd_dma2d.Init.Mode         = DMA2D_R2M;
  hlcd_dma2d.Init.ColorMode    = output_color_mode;//DMA2D_OUTPUT_ARGB8888;
  hlcd_dma2d.Init.OutputOffset = OffLine;

  hlcd_dma2d.Instance = DMA2D;

  /* DMA2D Initialization */
  if(HAL_DMA2D_Init(&hlcd_dma2d) == HAL_OK)
  {
	  if(HAL_DMA2D_ConfigLayer(&hlcd_dma2d, 1) == HAL_OK)
	  {
		if (HAL_DMA2D_Start(&hlcd_dma2d, input_color, (uint32_t)pDst, xSize, ySize) == HAL_OK)
		{
		  /* Polling For DMA transfer */
		  (void)HAL_DMA2D_PollForTransfer(&hlcd_dma2d, 100);
		}
	  }
  }
}

 

 

 Am I missing something? Thanks for your help!

0 REPLIES 0