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.

clock() function on TMS570 MCU Development Kit

I have a TMS570 MCU deve kit (usb stick).  I am trying to get some benchmarking information using the emulator.  I used the demo program as my baseline and added an additional element to the "switch" statement to call my benchmark code.  All runs correctly but I was intending to get timing information by bracketing the benchmart functions with reads of CPU cycles from the emulator via the "clock()" function.  It seems like this function always returns a value of 0.  Is there any timing or performance monitoring supported?  I don't want to invest a huge amount of time in measuring this benchmark.

Thanks in advance

Christopher Noll

  • Christopher,

    We have forwarded your question to our benchmarking experts and will have an answer for you shortly.

  • I am also facing same issue,clock function is always returning 0.I am using TI CCS5.0 and Compiler TIv4.9.5

    I am using below code

    start=clock();

    function();

    stop=clock();

    Both the variables(start and stop) are having values of 0.Can you please let me know why the value is 0?

  • Christopher,

    The Cortex R4F core has a build in unit to perform cycle count on different events. (Performance Monitor Unit).

    Here is an assembly code that provides the basic routine to initialize the PMU, Start count, Stop Count and Read results. 1667.perf_monitor_r4.asm

    The way to use it is easy. See the following example:

    int startTime, endTime, execTime = 0;

    Enable_Performance_Monitor(0);
    Performance_Monitor_Start(0);

    startTime = Performance_Monitor_Read_CycleCount(0);

    Code to be benchmarked;

    endTime = Performance_Monitor_Read_CycleCount(0);
    execTime = endTime - startTime ;

    Performance_Monitor_Stop(0);

    The result in execTime is the number of CPU cycles.

    Please have a try and let me know if this is helpful.

    For more information on PMU, please refer to ARM TRM and search for PMU.

    Regards,

    Jean-Marc