Fail to display expected colour after successful lcd initialization
I'm currently working on a project that involves using an STM32U5 microcontroller to drive a TFT LCD display through the MIPI DSI interface. After managing to initialize the LCD display (which shows the default layer in blue, indicating success), I've encountered a perplexing issue that I hope to find some assistance with here.
Despite the successful initialization, I'm only able to get a white image on the display, regardless of attempts to change the screen's color. Below is the approach I've taken, including the function intended to fill the layer0 with a specified color :
The function is designed to iterate through the frameBuffer, setting each pixel to a color defined by the RGB888 macro. After filling the buffer, I use HAL functions to update the LTDC frame buffer address and refresh the display. However, the screen remains white, even after executing this function with various color parameters.
Here are some specifics about my setup and what I have checked so far:
- The frameBuffer size and alignment are correctly configured for the display's resolution and color depth.
- I've double-checked the LTDC configuration, ensuring the pixel format, window size, and frame buffer address match the display's requirements.
- The display's datasheet was reviewed to confirm the correct timing parameters and color format (I've used RGB888).
I'm reaching out to see if anyone has faced a similar issue or could offer any insights into what might be going wrong. Any advice on additional debugging steps or configuration checks would be greatly appreciated. Could there be an issue with the way I'm using the HAL_LTDC_SetAddress and HAL_LTDC_Reload functions, or perhaps something else I'm overlooking?
Thank you in advance for your help and suggestions!
uint32_t frameBuffer[DISPLAY_WIDTH * DISPLAY_HEIGHT]; // Correct size for 32-bit access per pixel
#define RGB888(r,g,b) (((r) << 16) | ((g) << 8) | (b))
void FillScreenWithColor(uint8_t red, uint8_t green, uint8_t blue, uint32_t n_pixels) {
uint32_t color = RGB888(red, green, blue);
uint32_t* tempBuffer = frameBuffer; // Use a temporary pointer for iteration
while(n_pixels > 0) {
*tempBuffer = color; // Set the current pixel to the specified color
tempBuffer++; // Move to the next pixel
n_pixels--; // Decrement the pixel count
}
// Use the original framebuffer address to update LTDC, as tempBuffer has been incremented
HAL_LTDC_SetAddress(&hltdc, (uint32_t)frameBuffer, 0); // Assuming layer 0
HAL_LTDC_Reload(&hltdc, LTDC_RELOAD_IMMEDIATE); // Refresh the display
}
void InitializeDisplay(void) {
// Previous initialization code here...
// Enable the LCD, send Display ON command
HAL_DSI_ShortWrite(&hdsi, 0, DSI_DCS_SHORT_PKT_WRITE_P1, DSI_SET_DISPLAY_ON, 0x00);
// Start PWM Timer channel for backlight
(void)HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_2);
// Set maximum brightness (assuming 0-200 range for demonstration)
__HAL_TIM_SET_COMPARE(&htim8, TIM_CHANNEL_2, 200);
// Fill the screen with red color
FillScreenWithColor(255,0,0,480*480);
}
