cancel
Showing results for 
Search instead for 
Did you mean: 

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

BParh.1
Senior III

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!

7 REPLIES 7
HP
Senior III

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
Senior III

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

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).

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

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

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?

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
Up vote any posts that you find helpful, it shows what's working..

Thank you @Community member​  for your patience, I agree with you to consider the mechanics.

It is just unfortunately I am new to this, any documentation you could suggest me to understand this?

I am also interested to understand why my graphics flickering and the image looks distorted when the clock to LCD-TFT changed. I believe I need to address this somewhere else, but I'd appreciate some pointers.