Skip to main content
BParh.1
Senior III
March 25, 2021
Question

What is my refresh rate (frame per seconds) and can I modify it?

  • March 25, 2021
  • 7 replies
  • 5575 views

Hi Folks,

I just bought STM32F769I-DISCO kit and install Touchgfx. I need to develop application which need to handle time event, so it is crucial to know what is my screen refresh rate.

I read the MCU documentation it was not mentioned there. I read the Touchgfx, it just mentioned refresh rate is assumed to be 60 frame per second (fps). But how can I know for sure my refresh rate? Any doc mentione this? Is it written somewhere in the platform code? Can I modify it?

Thank you!

This topic has been closed for replies.

7 replies

HP_it
Senior II
March 25, 2021

The easiest way would probably be to look at the sysTick counter each time you enter the tGFX 'tick' method. compare how many cycles have passed since last time you entered and calculate the FPS based on the frequency of the MCU.

BParh.1
BParh.1Author
Senior III
March 30, 2021

thanks @HP​ , but unfortunately still not clear for beginner like me :). Care to elaborate or do you have code snippet?

HP_it
Senior II
March 30, 2021

Sure!

You can use a function called

xTaskGetTickCount();

(You might need to include some header file to get access to this) This will give you the current number of ticks. if you compare that number to the number you had last time you went through the loop you should get an idea of how fast you're going.

Similarly:

if(xTaskGetTickCount()-lastSync>syncInterval)
{
	lastSync = xTaskGetTickCount();
	do_something_here...
}

You have to create a variable (of the type long) called 'lastSync' which is the value the xTaskGetTickCount() function returned last.

syncInterval can be a regular int and is used to set the interval between entering the condition.

This snippet is not exactly what you're looking for but rather to time something without using delays.

THIS DOES NOT GUARANTEE CODE EXECUTION WITH A SPECIFIC INTERVAL - rather it allows for the code to check if it is time to perform certain tasks.

If you want code execution at a specific point in time you have to dig a bit deeper in the RTOS code (someone else here might know just where to adjust this)

Addition: Well, it might not guarantee that you execute your code at that EXACT moment, but it will usually be pretty close.

so - to answer your question of how to get the framerate:

  1. get the current number of ticks from xTaskGetTickCount()
  2. compare the new value to a value saved from the last time you got to this point
  3. Divide the clock speed with the difference between the new and old tick value - that is how much time you need to render a frame
  4. divide one second by the amount found in 3 and you should have a value for FPS
  5. update the value you want to compare with (so when you roll back around you have an updated value to compare against)

I don't have access to cubeIDE right now so might get different results.

Also - you can have a look into some of the demos provided by tGFX. they might have a FPS counter (or was it only MCU load? I can't remember).

Tesla DeLorean
Guru
March 30, 2021

Frame rate of panel determined by pixel clock divided by line totals​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
BParh.1
BParh.1Author
Senior III
April 13, 2021

Thanks @Community member​ , but could you elaborate please? I open my clock configuration using STM32CubeMX, but I could not find anything like 'pixel clock' and what is total lines?

Tesla DeLorean
Guru
April 13, 2021

Line totals would be all the pixels described on the horizontal ie sync, front/back porches, active. and by the vertical ones.

It might help to understand the geometries and function of scanning raster displays, how the image paints, and how the screen size/time further relates to the frame rate.

Consider the mechanics rather than relying on button pressing in CubeMX

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..