AnsweredAssumed Answered

Bug in BSP_LCD_ReadPixel

Question asked by kuchura.yury on Jul 22, 2016
Latest reply on Dec 21, 2016 by Imen D

Using CubeF7 with STM32F746G Discovery board.

Found a weird bug in STM32Cube_FW_F7_V1.4.0\Drivers\BSP\STM32746G-Discovery\stm32746g_discovery_lcd.c :

uint32_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos)
  uint32_t ret = 0;
  if(hLtdcHandler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
    /* Read data value from SDRAM memory */
    ret = *(__IO uint32_t*) (hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (2*(Ypos*BSP_LCD_GetXSize() + Xpos)));

The highlighted multiplier of 2 must be replaced with 4, otherwise the code either returns data for the wrong pixel, or causes hardfault crash trying to access non-existing memory.

Similar changes probably should be made in the code below (for RGB888 format).