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.

TMS320F28335: How to find current time or current execution time?

Part Number: TMS320F28335

Hi TI community,

I am looking for a current time or current execution time for my code. How can i find this? I need this for my loop:

For example:

Loop->

double curr_time....(find??);

double last_time = 0;

dt = (curr_time -  last_time);

last_time = curr_time; 

Please suggest how i can calculate this current time or current execution time?

Thanks

Regards

Arsalan

  • Hi Ki,

    Thanks for your reply.

    I checked this link and get the value in clock cycle like 4345 and next cycle 4347 using breakpoints and then calculated the time (4345 * 1/150M = 0.00002896). Problem is i have to manually calculate each time profile clock cycle for my loop. if the while loop runs 2nd time then this cycle will change accordingly and then i have to again measure the profile clock cycle.

    Is it possible if i can get the profile cycle without measuring each time and then it can be used each time whatever the loop cycle could be. It checks on spot and then measure accordingly? I mean like:  get(Profile_clock). Because my while loop is continuous and we don't know what value of my profile clock be. If we fix the value of Profile_clock = 0.0000289 then in my while loop, the dt will become "0" which is not correct.

    In CCS:

    double last_time = 0;

    while(1)
    {

    Duty_cycle_ratio = ((double)((int32)PWM_Duty)) / 283; // This number is a ratio between 0-1
    A1= (Duty_cycle_ratio * 3.0); // Analog Input voltage
    dt = (0.000028966 - last_time); //  Profile_clock.............................................................................This line must get profile clock automatically
    last_time = 0.000028966
    e = (ref - A1);
    se = (se + e) * dt;
    de = (e-le) / dt;
    pid_out = (Kp*e) + (Ki*se) + (Kd*de); // Pid equation

    In Arduino: 

    In Arduino, the controller calculates automatically through this line.....double now = millis(); 

    If I can get this kind of function or any idea for my CCS code, can resolve this issue.

    Please suggest accordingly

    Regards

    Arsalan

  • Please note that profiling options on your device is limited. The profile clock is quite basic in functionality. It is useful to measure the cycles from point A to point B. There is some configuration you can do, such as auto-reset to 0 in every run, etc. But that is about it. You also cannot access the profile clock from your application code. 

    There is other instrumentation you can do from your code however. I will bring this thread to the attention of the device experts who can provide more details.

    Thanks

    ki

  • This page https://software-dl.ti.com/C2000/docs/optimization_guide/phase2.html gives details on using the CPU Timer(s) we have on the C2000 devices to measure code execution time.  There is sample function code on this page as well.  This should accomplish what you are after.

    Best,

    Matthew