2021-03-25 01:51 AM
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!
2021-03-25 03:03 AM
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.
2021-03-30 01:08 AM
thanks @HP , but unfortunately still not clear for beginner like me :). Care to elaborate or do you have code snippet?
2021-03-30 04:44 AM
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:
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).
2021-03-30 05:05 AM
Frame rate of panel determined by pixel clock divided by line totals
2021-04-12 11:32 PM
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?
2021-04-12 11:46 PM
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
2021-04-12 11:57 PM
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.