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.

TDA2PXEVM: HI,I think there is a bug in your code ,PLease check it out,Or help me understrand it

Part Number: TDA2PXEVM


 have some questions about understanding your code below; in C:\PROCESSOR_SDK_RADAR_03_07_00_00\vision_sdk\links_fw\src\rtos\utils_common\src\utils.c

UInt64 Utils_getCurTimeInUsec(void)
{
static UInt32 cpuMhz = 700U; /* default */
static Bool isInitialized = (Bool)FALSE;

Types_Timestamp64 ts64;
UInt64 curTs;

if(!isInitialized)
{
/* do this only once */

Types_FreqHz cpuHz;

isInitialized = (Bool)TRUE;

Timestamp_getFreq(&cpuHz);

cpuMhz = cpuHz.lo / (1000U*1000U); /* convert to Mhz */

Vps_printf(" *** UTILS: CPU MHz = %d Mhz ***\n", cpuMhz);
}

Timestamp_get64(&ts64);

curTs = (UInt64) ts64.hi << (UInt64)16U;
curTs = (UInt64) curTs << (UInt64)16U;
curTs = (UInt64) curTs | (UInt64)ts64.lo;

return (curTs/cpuMhz);

this will make the /cpuMh=20MHz all the time,

  • Hi,

    cpuMh should be same all time, this is clock frequency of that particular core.

    The formula for measuring time is

    Time taken = no of cycles taken /  frequency

    You can verify this API by doing the below changes in your code

    uint64 first = Utils_getCurTimeInUsec()

    sleepms(100) // sleep 100ms

    uint64 last= Utils_getCurTimeInUsec()

    //Now take the difference

    unit64 diff = first - last 

    The answer will approximately 100ms

    Thanks

    Gaviraju

    Thanks

    Gaviraju