2025-03-24 2:54 PM
I have just started using TouchGFX on an Stm32H7A3ZIQ Nucleo board. I managed to setup the LTDC correctly and am able to change the color of the screen, which makes me assume that the LTDC is setup correctly.
After setting up TouchGFX with FreeRTOS, following the documentation, I keep getting stuck at a blackscreen.
I have configured touchgfx the following way:
Following the docs, I have enabled FreeRTOS, set the heap size to 70 000 Bytes and added the following task:
I have enabled the LTDC interrupt to ensure that the LTDC vsync signal drives touchgfx:
and added the following line to main.c after the LTDC configuration:
LTDC->IER |= LTDC_IER_LIE;
as well as the line to the interrupt handler:
void LTDC_IRQHandler(void)
{
/* USER CODE BEGIN LTDC_IRQn 0 */
/* USER CODE END LTDC_IRQn 0 */
HAL_LTDC_IRQHandler(&hltdc);
/* USER CODE BEGIN LTDC_IRQn 1 */
HAL_LTDC_ProgramLineEvent(&hltdc, 0);
/* USER CODE END LTDC_IRQn 1 */
}
In TouchGFX designer I have created a very simple screen:
Clicked generate and ensured that the code is in the project:
Does someone have an idea what I might be missing?
Solved! Go to Solution.
2025-03-25 4:23 AM
Ok so after debugging for some hours I found it sus that the docs tell me to add this line:
Since the interrupt handler generated by touchgfx:
void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef* hltdc)
{
if (!HAL::getInstance())
{
return;
}
if (LTDC->LIPCR == lcd_int_active_line)
{
//entering active area
HAL_LTDC_ProgramLineEvent(hltdc, lcd_int_porch_line);
HAL::getInstance()->vSync();
OSWrappers::signalVSync();
// Swap frame buffers immediately instead of waiting for the task to be scheduled in.
// Note: task will also swap when it wakes up, but that operation is guarded and will not have
// any effect if already swapped.
HAL::getInstance()->swapFrameBuffers();
GPIO::set(GPIO::VSYNC_FREQ);
}
else
{
//exiting active area
HAL_LTDC_ProgramLineEvent(hltdc, lcd_int_active_line);
// Signal to the framework that display update has finished.
HAL::getInstance()->frontPorchEntered();
GPIO::clear(GPIO::VSYNC_FREQ);
}
}
writes to the LIPCR register via the HAL_LTDC_ProgramLineEvent function and adding the line:
HAL_LTDC_ProgramLineEvent(&hltdc, 0);
would overwrite it every time since it's called right after the LineEvent Handler.
Removing this lines fixed my problems.
Could someone explain why the docs tell us to do so or if this is a bug?
2025-03-25 4:23 AM
Ok so after debugging for some hours I found it sus that the docs tell me to add this line:
Since the interrupt handler generated by touchgfx:
void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef* hltdc)
{
if (!HAL::getInstance())
{
return;
}
if (LTDC->LIPCR == lcd_int_active_line)
{
//entering active area
HAL_LTDC_ProgramLineEvent(hltdc, lcd_int_porch_line);
HAL::getInstance()->vSync();
OSWrappers::signalVSync();
// Swap frame buffers immediately instead of waiting for the task to be scheduled in.
// Note: task will also swap when it wakes up, but that operation is guarded and will not have
// any effect if already swapped.
HAL::getInstance()->swapFrameBuffers();
GPIO::set(GPIO::VSYNC_FREQ);
}
else
{
//exiting active area
HAL_LTDC_ProgramLineEvent(hltdc, lcd_int_active_line);
// Signal to the framework that display update has finished.
HAL::getInstance()->frontPorchEntered();
GPIO::clear(GPIO::VSYNC_FREQ);
}
}
writes to the LIPCR register via the HAL_LTDC_ProgramLineEvent function and adding the line:
HAL_LTDC_ProgramLineEvent(&hltdc, 0);
would overwrite it every time since it's called right after the LineEvent Handler.
Removing this lines fixed my problems.
Could someone explain why the docs tell us to do so or if this is a bug?