2024-02-02 12:24 AM
Hello community,
I am trying to show a shape (line) or text on a background a TFT parallel RGB Display. I am using the NUCLEOH7A3 board without external RAM and a 800x320 Display.
Everything works fine using TouchGFX. So it is not a hardware problem or CLK. But I want to program it buy my self using other libraries.
I copied the files and functions from the STM32H7B3i Discovery LCD example (stm32h7b3i_discovery_lcd.c and stm32h7b3i_discovery_lcd.h) and changed them a bit.
The function UTIL_LCD_Clear() works fine (except of weired pixels on the top (line1 or 2)) but the text and the line are not shown. And if I take the function UTIL_LCD_Clear() out, the text and the line are shown but the Display background looks weird with weired pixels. (see images)
So why the text and the horizontal line are not showing after filling the screen with UTIL_LCD_Clear()?
(Nevermind about the horizontal line now. It had another color, that I could see. But now because I've already made the pictures, I can ensure you that the line can be shown like the text.)
Am I missing something? Does the FBStartadress (initilized with AXI SRAM1) need to be changed each time you want to show something else on the display? (I thought the functions increment the adress automatically, so I think it is not a problem of the RAM adress...)
Thanks alot ! I appreciate your help!
Here is the main code:
int main(void)
{
HAL_Init();
SystemClock_Config();
PeriphCommonClock_Config();
MX_GPIO_Init();
MX_USART3_UART_Init();
MX_USB_OTG_HS_USB_Init();
MX_ADC2_Init();
MX_I2C1_Init();
MX_I2C3_Init();
MX_CRC_Init();
MX_DMA2D_Init();
/*##-1- LCD Configuration ##################################################*/
BSP_LCD_Init(0, LCD_ORIENTATION_LANDSCAPE);
UTIL_LCD_SetFuncDriver(&LCD_Driver);
UTIL_LCD_SetDevice(0);
UTIL_LCD_Clear(UTIL_LCD_COLOR_WHITE);
UTIL_LCD_SetFont(&Font24);
UTIL_LCD_SetBackColor(UTIL_LCD_COLOR_LIGHTBLUE);
UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_DARKBLUE);
UTIL_LCD_DisplayStringAt( 0, 160, (uint8_t *)"Hello World", CENTER_MODE);
BSP_LCD_DrawHLine(0, 200, 200, 200, LCD_COLOR_ARGB8888_WHITE);
while (1)
{
}
}
Here are the LCD library functions:
int32_t BSP_LCD_Init(uint32_t Instance, uint32_t Orientation)
{
return BSP_LCD_InitEx(Instance, Orientation, LCD_PIXEL_FORMAT_ARGB8888, LCD_DEFAULT_WIDTH, LCD_DEFAULT_HEIGHT);
}
int32_t BSP_LCD_InitEx(uint32_t Instance, uint32_t Orientation, uint32_t PixelFormat, uint32_t Width, uint32_t Height)
{
int32_t ret = BSP_ERROR_NONE;
uint32_t ltdc_pixel_format;
MX_LTDC_LayerConfig_t config;
if((Orientation > LCD_ORIENTATION_LANDSCAPE) || (Instance >= LCD_INSTANCES_NBR) || \
((PixelFormat != LCD_PIXEL_FORMAT_RGB565) && (PixelFormat != LTDC_PIXEL_FORMAT_RGB888) && (PixelFormat != LTDC_PIXEL_FORMAT_ARGB8888)))
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
if(PixelFormat == LCD_PIXEL_FORMAT_RGB565)
{
ltdc_pixel_format = LTDC_PIXEL_FORMAT_RGB565;
Lcd_Ctx[Instance].BppFactor = 2U;
}
else /* LCD_PIXEL_FORMAT_RGB888 */
{
ltdc_pixel_format = LTDC_PIXEL_FORMAT_ARGB8888;
Lcd_Ctx[Instance].BppFactor = 4U;
}
/* Store pixel format, xsize and ysize information */
Lcd_Ctx[Instance].PixelFormat = PixelFormat;
Lcd_Ctx[Instance].XSize = Width;
Lcd_Ctx[Instance].YSize = Height;
/* Initializes peripherals instance value */
hlcd_ltdc.Instance = LTDC;
hlcd_dma2d.Instance = DMA2D;
if(MX_LTDC_Init(&hlcd_ltdc, Width, Height) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
/* Configure default LTDC Layer 0. This configuration can be override by calling
BSP_LCD_ConfigLayer() at application level */
config.X0 = 0;
config.X1 = Width;
config.Y0 = 0;
config.Y1 = Height;
config.PixelFormat = ltdc_pixel_format;
config.Address = 0x24000000; //AXI SRAM1 adress taken from the reference manual
if(MX_LTDC_ConfigLayer(&hlcd_ltdc, 0, &config) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
/* By default the reload is activated and executed immediately */
Lcd_Ctx[Instance].ReloadEnable = 1U;
}
return ret;
}
Solved! Go to Solution.
2024-02-06 04:35 AM
I found out the problem!
Variables were saved in the same memory, that I starded from (AXI SRAM1).
The display is 800x320 and I used ARGB8888. So the hole internal 1MB RAM was used. There was a conflict between the variables and the Display pixels written at the same adress.
When I changed to RGB565 and changed the FBStartAdress to AXI SRAM2 everything worked!
2024-02-06 04:35 AM
I found out the problem!
Variables were saved in the same memory, that I starded from (AXI SRAM1).
The display is 800x320 and I used ARGB8888. So the hole internal 1MB RAM was used. There was a conflict between the variables and the Display pixels written at the same adress.
When I changed to RGB565 and changed the FBStartAdress to AXI SRAM2 everything worked!
2024-02-07 02:51 AM
Hello @chaari ,
Glad that you have found a solution to your issue. Thank you for sharing your solution with the community it can help people facing the same problem :)
2024-04-20 10:15 PM
Could you share also the include file to use this library ?