2018-06-08 10:30 AM
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); }
2018-06-08 03:39 PM
Problem is ltdc config file
2018-06-08 03:41 PM
Thanks for your reply. But what's the problem with it, and how would I fix it ?
2018-06-08 03:52 PM
The example assumes a bitmap BMP, I'm using a non BMP format. Just a raw bytes bitmap. That's the issue
2018-06-08 03:58 PM
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); }}2018-06-08 05:49 PM
Look at example
....\STM32Cube\Repository\STM32Cube_FW_F4_V1.21.0\Projects\STM32F429I-Discovery\Applications\Display\LTDC_Paint
2018-06-08 06:03 PM
config file for dma2 & sdram & ltdc for example and for your file must be similar
2018-06-08 06:06 PM
You can see memory in debugger & find out where the record is going