cancel
Showing results for 
Search instead for 
Did you mean: 

beginFrame and endFrame is locked after a while

Epamuk
Associate III

Hello,

I have a project with STM32L4R9AI and touchgfx. I use DSI for amoled display. I am developing codes for months. At some point screen is started to be locked ( no changes in screen ). While debugging the code when I look at the freeRtos task table it seems that Touchgfx task is blocked. Other threads (harware, sensor, BLE ..... ) work without problem. In this case, code never comes to endFrame(), beginFrame() and OSWrappers::waitForVSync() functions but tear effect interrrupt works. Code comes to tear effect irq handler but it can not refresh display because refreshRequested is false. refreshRequested cannot be true because code never comes to endFrame()

this is may code

bool STM32HAL_DSI::beginFrame()
{
    refreshRequested = false;
    return HAL::beginFrame();
}
 
void STM32HAL_DSI::endFrame()
{
 
      HAL::endFrame();
      if (frameBufferUpdatedThisFrame)
      {
          refreshRequested = true;
      }else {
        __NOP();
      }
    
 
extern "C"
__irq void DSI_IRQHandler(void)
{
    if (__HAL_DSI_GET_IT_SOURCE(&hdsi, DSI_IT_TE))
    {
        // Tearing effect interrupt. Occurs periodically (every 15.7 ms on 469 eval/disco boards)
        __HAL_DSI_CLEAR_FLAG(&hdsi, DSI_IT_TE);
 
        if (osKernelRunning() > 0)
        {
            GPIO::set(GPIO::VSYNC_FREQ);
            HAL::getInstance()->vSync();
            OSWrappers::signalVSync();
            if (!doubleBufferingEnabled && HAL::getInstance())
            {
                // In single buffering, only require that the system waits for display update to be finished if we
                // actually intend to update the display in this frame.
                HAL::getInstance()->lockDMAToFrontPorch(refreshRequested);
            }
        } 
 
        if (refreshRequested && !displayRefreshing)
        {
         
            if (osKernelRunning() > 0)
            {
                // We have an update pending.
                if (doubleBufferingEnabled && HAL::getInstance())
                {
                    // 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();
                }
                displayRefreshing = true;
            }
            //Set update whole display region.
            LCD_SetUpdateRegion(0);
 
            // Transfer a quarter screen of pixel data.
            HAL_DSI_Refresh(&hdsi);
        }
        else
        {
            if (osKernelRunning() > 0)
            {
                GPIO::clear(GPIO::VSYNC_FREQ);
            }
        }
    }
 
    if (__HAL_DSI_GET_IT_SOURCE(&hdsi, DSI_IT_ER))
    {
        // End-of-refresh interrupt. Meaning one of the 4 regions have been transferred.
        __HAL_DSI_CLEAR_FLAG(&hdsi, DSI_IT_ER);
 
        //        HAL_DSI_Stop(&hdsi);
        //
        //        //LTDC_LAYER(hltdc, 0)->CFBAR = (uint32_t)currFbBase;
        //        //LTDC->SRCR = (uint32_t)LTDC_SRCR_IMR;
        //        LCD_SetUpdateRegion(0);
        //        //DSI->WCR |= DSI_WCR_DSIEN;
        //
        //        HAL_DSI_Start(&hdsi);
 
        if (osKernelRunning() > 0)
        {
            GPIO::clear(GPIO::VSYNC_FREQ);
 
            displayRefreshing = false;
            if (HAL::getInstance())
            {
                // Signal to the framework that display update has finished.
                HAL::getInstance()->frontPorchEntered();
            }
        }
    }
}      
 
    
}

I see a topic about endFrame on known issues at old version and I add this piece of code to mine but it doesnt solve problem. Sometimes after 1 minute, sometimes after 15 minutes toucfgfx is locked.

void STM32HAL_DSI::endFrame()
{
    if (dma.isDMARunning())
    {
//while (OSWrappers::tryTakeFrameBufferSemaphore()==pdFALSE){
      OSWrappers::tryTakeFrameBufferSemaphore();//==pdFALSE){
      //  __NOP();
     // }
    
    }
      
      HAL::endFrame();
      if (frameBufferUpdatedThisFrame)
      {
          refreshRequested = true;
      }else {
        __NOP();
      }
    
      
 
    
}

4 REPLIES 4
Romain DIELEMAN
ST Employee

Hi,

Just to have a better context, what version of TouchGFX are you using ? Are you using a custom hardware or an ST kit (STM32L4R9AI dk or eval boards) ?

/Romain

Epamuk
Associate III

I was using touchgfx 4.14 and migratted to 4.15. two days ago. I have problem in both version. I use a custom hardware.

JYi.3
Associate II

I ran into the same issue. What was the solutoin?

How did you fix the issue?