cancel
Showing results for 
Search instead for 
Did you mean: 

Drawing a bitmap using 2D DMA on STMF32F4

Ahmed Tolba
Associate II
Posted on June 08, 2018 at 19:30

I'm trying to draw a bitmap using 2D DMA, so I have the address of the destination which is the front buffer, and then I read a line from the bitmap, blit it using the 2D DMA.. I get scanlines, and garbage image. Not sure where is the problem

/**

* @brief Displays a bitmap picture loaded in the internal Flash (32 bpp). * @param X: the bmp x position in the LCD * @param Y: the bmp Y position in the LCD * @param pBmp: Bmp picture address in the internal Flash */ void BSP_LCD_DrawBitmap(uint16_t layer,uint32_t X, uint32_t Y, const uint8_t *pBmp) { uint32_t index = 0, width = 0, height = 0, bitpixel = 0; uint32_t address; uint32_t inputcolormode = 0; /* Get bitmap data address offset */ index = 0;

/* Read bitmap width */

width = 240;

/* Read bitmap height */

height = 320;

/* Read bit/pixel */

bitpixel = 2; if ( ActiveLayer == 0 ) { address = LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress ; } else { address = LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + 240*320*2; } inputcolormode = CM_RGB565; /* Convert picture to RGB565 pixel format */ for(index=0; index < height; index++) { /* Pixel format conversion */ ConvertLineToRGB565((uint16_t *)pBmp, (uint16_t *)address, width, inputcolormode);

/* Increment the source and destination SCREENs */

address+= ((BSP_LCD_GetXSize() - width + width)*2); pBmp += width*(bitpixel/2); }

 

7 REPLIES 7
Posted on June 09, 2018 at 00:39

Problem is ltdc config file

Ahmed Tolba
Associate II
Posted on June 09, 2018 at 00:41

Thanks for your reply. But what's the problem with it, and how would I fix it ?

Ahmed Tolba
Associate II
Posted on June 09, 2018 at 00:52

The example assumes a bitmap BMP, I'm using a non BMP format. Just a raw bytes bitmap. That's the issue

Ahmed Tolba
Associate II
Posted on June 09, 2018 at 00:58

I tried to fix the ltdc config.

here is updated code

I try to draw red color to frame buffer, but nothing is drawn

void BSP_LCD_DrawBitmap(uint16_t layer,uint32_t X, uint32_t Y, const uint16_t *pBmp)

{

uint32_t index = 0, width = 0, height = 0, bitpixel = 0;

uint32_t address;

uint32_t inputcolormode = 0;

/* Get bitmap data address offset */

index = 0;

/* Read bitmap width */

width = 240;

/* Read bitmap height */

height = 320;

/* Read bit/pixel */

bitpixel = 2;

address = LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress;

pBmp+=width;

inputcolormode = CM_RGB565;

uint16_t p = 0xFF00;

/* Convert picture to RGB565 pixel format */

for(index=0; index < height; index++)

{

/* Pixel format conversion */

ConvertLineToRGB565(&p, (uint16_t *)address, width, inputcolormode);

/* Increment the source and destination SCREENs */

address+= ((BSP_LCD_GetXSize() - width + width)*4);

pBmp -= width*(bitpixel/8); }

}
Posted on June 09, 2018 at 00:49

Look at example

....\STM32Cube\Repository\STM32Cube_FW_F4_V1.21.0\Projects\STM32F429I-Discovery\Applications\Display\LTDC_Paint

Posted on June 09, 2018 at 01:03

config file for dma2 & sdram & ltdc for example and for your file must be similar

Posted on June 09, 2018 at 01:06

You can see memory in debugger & find out where the record is going