This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

GTC time module problem

Part Number: TDA4VM


Hello experts,

I made simple test related to the system time on TDA4 and the results are showing time difference between GTC module and Linux time. The test compares the elapsed time in uSec for certain period of time (1s, 10s and 100s). The test results are showing that GTC clock (time) is slower than the Linux clock (time).

SDK version is 7.02 and I am running Linux on A72 core.

This is code snippet of the test application:

uint32_t sleepTime = 1;
for(i = 0; i < 3; i++)
{
    printf("Test with sleep = %d s\n", sleepTime);

    globalTimestamp1 = appLogGetGlobalTimeInUsec();
    localTimestamp1 = appLogGetLocalTimeInUsec();

    sleep(sleepTime);

    globalTimestamp2 = appLogGetGlobalTimeInUsec();
    localTimestamp2 = appLogGetLocalTimeInUsec();

    localDiff = localTimestamp2 - localTimestamp1;
    globalDiff  = globalTimestamp2 - globalTimestamp1;

    printf("local   diff: %ld  us \n", localDiff);
    printf("global  diff: %ld  us \n", globalDiff);
    printf("local-global: %ld  us \n", localDiff - globalDiff);
    printf("---------------------------------------\n");
    sleepTime *= 10;
}

Here are the test results:

Test with sleep = 1 s
local   diff: 1000062  us 
global  diff: 999994  us 
local-global: 68  us 
---------------------------------------
Test with sleep = 10 s
local   diff: 10000063  us 
global  diff: 9999381  us 
local-global: 682  us 
---------------------------------------
Test with sleep = 100 s
local   diff: 100000072  us 
global  diff: 99993243  us 
local-global: 6829  us 
---------------------------------------

Please, can you check these measurements? What could be the reason for this time difference?

Regards,
Darko

  • Hi Darko,

    I would suggest to measure the local and global separately, something like below, because both of them can involve 64bit division operation, which can take longer as the number value increases. 

     

    globalTimestamp1 = appLogGetGlobalTimeInUsec();

    sleep(sleepTime);

    globalTimestamp2 = appLogGetGlobalTimeInUsec();

    localTimestamp1 = appLogGetLocalTimeInUsec();

    sleep(sleepTime);

    localTimestamp2 = appLogGetLocalTimeInUsec();

    localDiff = localTimestamp2 - localTimestamp1;
    globalDiff = globalTimestamp2 - globalTimestamp1;

    printf("local diff: %ld us \n", localDiff);
    printf("global diff: %ld us \n", globalDiff);
    printf("local-global: %ld us \n", localDiff - globalDiff);
    printf("---------------------------------------\n");
    sleepTime *= 10;

    Regards,

    Brijesh

  • Hi Brijesh,

    I tested with your code suggestion, but the results are the same.

    Time difference between GTC time (global time) and Linux time (local time) is always present. This diff is about 68us per second.

    Do you have any idea why these clocks are not in synchronization?

    Regards,
    Darko

  • Hi Darko,

    I think the issue was the increasing difference between local and global time for the longer duration. Isn't it? Do you still see increase in the difference? 

    Regards,

    Brijesh

  • Hi Brijesh,

    Yes, the problem is increasing difference between local and global time for the longer duration.

    globalTimestamp1 = appLogGetGlobalTimeInUsec();

    sleep(sleepTime);

    globalTimestamp2 = appLogGetGlobalTimeInUsec();

    localTimestamp1 = appLogGetLocalTimeInUsec();

    sleep(sleepTime);

    localTimestamp2 = appLogGetLocalTimeInUsec();

    localDiff = localTimestamp2 - localTimestamp1;
    globalDiff = globalTimestamp2 - globalTimestamp1;

    printf("local diff: %ld us \n", localDiff);
    printf("global diff: %ld us \n", globalDiff);
    printf("local-global: %ld us \n", localDiff - globalDiff);
    printf("---------------------------------------\n");
    sleepTime *= 10;

    I run test with this code above and here are the results:

    Test with sleep = 1 s
    local   diff: 1000059  us 
    global  diff: 999991  us 
    local-global: 68  us 
    ---------------------------------------
    Test with sleep = 10 s
    local   diff: 10000082  us 
    global  diff: 9999378  us 
    local-global: 704  us 
    ---------------------------------------
    Test with sleep = 100 s
    local   diff: 100000064  us 
    global  diff: 99993233  us 
    local-global: 6831  us 
    ---------------------------------------

    Time difference between global and local time is still present (and it is same as with my code). So problem is not in the test and C code.

    It seams that GTC clk is not exactly 200MHz. If I made good calculation from results above, the GTC clk is around 199,986338009MHz  and that could be problem for inaccurate time of GTC module. What do you think?

    What do you suggest to resolve this issue?

    Regards,
    Darko

  • Hi Darko,

    I really doubt that GTC is running at lower frequency. I still think there is some calculation issue. Can you please read 64bit GTC register value and calculate the value manually?

    Regards,

    Brijesh