LTDC Interrupt Handling and TouchGFXGeneratedHAL::enableLCDControllerInterrupt() Issue
Hello Community,
I'm currently facing a challenging issue in my project that involves the TouchGFX framework on an STM32u59dk board, specifically related to the LTDC interrupt mechanism and its integration with the TouchGFX HAL.
Despite having the LTDC interrupt enabled and confirmed to be triggering correctly, I've noticed that the void TouchGFXGeneratedHAL::enableLCDControllerInterrupt() method is not being called in my application's execution flow. This method is crucial for configuring the interrupt handling in sync with the TouchGFX framework, particularly for managing the display's active and porch lines for smooth frame rendering.
The core of the issue seems to lie in the initialization of lcd_int_active_line and lcd_int_porch_line variables, which remain at 0. This is a direct consequence of TouchGFXGeneratedHAL::enableLCDControllerInterrupt() not being executed:
void TouchGFXGeneratedHAL::enableLCDControllerInterrupt()
{
lcd_int_active_line = (LTDC->BPCR & 0x7FF) - 1;
lcd_int_porch_line = (LTDC->AWCR & 0x7FF) - 1;
/* Sets the Line Interrupt position */
LTDC->LIPCR = lcd_int_active_line;
/* Line Interrupt Enable */
LTDC->IER |= LTDC_IER_LIE;
}
Without these critical values being set, the system fails to correctly manage the timing for frame buffer swapping and signaling the end of frame rendering in the HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef* hltdc) function. This effectively hampers the smooth operation and synchronization of frame updates, leading to potential rendering issues.
Here's how the issue manifests in the HAL_LTDC_LineEventCallback:
- The condition if (LTDC->LIPCR == lcd_int_active_line) is intended to trigger actions at the start of the active display area. However, due to lcd_int_active_line and lcd_int_porch_line not being set, the intended synchronization and frame buffer management do not occur as designed
here is the lineEvent function :
extern "C"
{
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);
}
}
}
This situation has led me to reach out for assistance. Has anyone encountered a similar scenario where TouchGFXGeneratedHAL::enableLCDControllerInterrupt() does not get called, resulting in uninitialized line interrupt configurations? Any insights into potential misconfigurations or suggestions would be greatly appreciated.
