cancel
Showing results for 
Search instead for 
Did you mean: 

Tick Rate Slows to 1 Tick per 2.5 Seconds

DSwea.1
Associate III

I am working with a project in TouchGFX Designer/Generator 4.17 and STM32CubeIDE 1.7.0, which uses the LTDC interrupt from the display to drive the main display loop. The display is configured according to the manufacturer's specifications, and TouchGFX generator generates code to enable the VSYNC interrupt, which calls OSWrappers::signalVSync() to unblock the main loop. Adding a counter to signalVSync() and examining its value after an elapsed time indicates that the VSYNC interrupt, HAL_LTDC_IRQHandler(), is occurring at a rate of approximately 170 times per second and that signalVSync() is being called at half that rate, or 85 times per second:

unsigned int signalCount = 0;

void OSWrappers::signalVSync()

{

  signalCount++;

  osMessageQueuePut(vsync_queue, &dummy, 0, 0);

}

When rendering is done, a corresponding TouchGFX-generated call is made to OSWrappers::waitForVSync() to indicate that rendering is complete. A similar analysis shows that waitForVSync() is also being called at a rate of 85 per second:

unsigned int waitCount = 0;

void OSWrappers::waitForVSync()

{

  waitCount++;

  uint32_t dummyGet;

  // First make sure the queue is empty, by trying to remove an element with 0 timeout.

  osMessageQueueGet(vsync_queue, &dummyGet, 0, 0);

  // Then, wait for next VSYNC to occur.

  osMessageQueueGet(vsync_queue, &dummyGet, 0, osWaitForever);

}

All this translates to a received tick rate in the TouchGFX application of 85 ticks per second.

However, at some point, sometimes sooner, sometimes only after an extended period of time, interaction with the display becomes impossible---buttons do not respond, screen transitions do not happen, etc. Setting a breakpoint in the tick handler verifies that the tick is actually still occurring, but at a rate of app. 1 tick every 2.5 seconds. This situation has been seen to occur with a wide range of task mixes, including when the GUI task is the only one running (all others removed), and with a variety of screen mixes. In fact, the slowdown has been seen to occur most reliably on a project with single screen with a large flex button in the middle.

Once the slowdown occurs, it is seen that signalVSync() is still being invoked at 85Hz, while waitForVSync(), like the tick, is only being invoked at 0.4Hz.

My sense is that this issue may be a result of the faster clock rate of 85Hz, which is approximately 42% higher than the normal 60Hz rate. So, as this is basically a show-stopper issue, I welcome comments or suggestions as to how to address the problem.

8 REPLIES 8
MM..1
Chief II

Check model tick or all handletick for blocking parts.

Michael K
Senior III

Interesting problem. Part number and datasheet for the screen and touchscreen might be helpful.

A problem I recently faced involved a touchscreen that was going to sleep after a certain amount of time. The application template I was using disabled IRQs and waited for the I2C to complete, but when the touchscreen was asleep its i2c was shut down. With no IRQs, the HAL function never timed out and the code locked up. If your touchscreen regularly drops into and out of a sleep mode automatically, it may be locking the system up while it's being polled and asleep, but then unlocking when the touchscreen comes out of sleep again and responds. The touchscreen sampling is done in the touchgfx task, so if it's blocking than you'll get slower waitForVsync calls than signalVsync.

It's probably not the LCD. You've identified the LTDC still ticks away. The refresh rate probably isn't a problem either. If there's enough time to complete the task, TGFX will happily tick at 85Hz (I'm running a project at 90). If you'd like to change it, most screens have a command to change the hardware refresh rate. For example, for the ST7789V2 it's FRCTRL2 (C6h): Frame Rate Control in Normal Mode.

Good luck.

Embedded UI/UX Consulting: cadenza.design
DSwea.1
Associate III

Processor is a STM32H777 running at 216MHz, and I think you're likely right about 85Hz rate not being the problem. In the simplest case, with only a single button in the middle of the screen and no tick handlers, the problem persists. Pretty much kills any possibility of user interaction. The remaining tasks are running at normal speed, but something in the TGFX task keeps blocking.

MM..1
Chief II

You dont show any config, then reply is hard or immpossible. In TouchGFX config MX you set LTDC timebase or Custom? You set RTOS 1 or 2 or you write create project

 TouchGFX Designer/Generator 4.17 and STM32CubeIDE 1.7.0

what is first? USW...

Normal way to custom LCD is start create project from IDE new project wizard MX.

Did you check the if the touchscreen is blocking? It's in STM32TouchController.cpp, function STM32TouchController::sampleTouch(int32_t& x, int32_t& y)

Embedded UI/UX Consulting: cadenza.design

Sorry for the late reply---it took a bit to have time to look into it. But yes, you're correct that the issue is in the touchscreen code. But it's not a blocking issue per-se, but instead an apparent bug in the I2C HAL code that accesses the display registers. One of the other engineers on the project will be looking into it.

Thanks very much for your comments and suggestions, and for taking the time to consider and reply to the issue. Looks like we're on the track of the problem.

Any updates on your solution? I'm curious to know if you ended up solving it completely.

Embedded UI/UX Consulting: cadenza.design

Sorry to say we haven't yet solved the problem. We have narrowed it down, but...

We'll definitely have to find a solution as the situation is a show stopper for the entire project.