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.

[FAQ] CLA: How can I calculate the duration of a task?

Q: How can I calculate how much time a CLA task takes to execute?  or How do I profile a CLA task? What overhead should be included?

 

 

  • A:

    Using a timer:

    One method is to use a free running timer to capture the number of cycles the task execution took.  The CLA has access to the PWM timers.  As an example you could capture the number of cycles in C as follows:

    1. At the start of the task, CLA reads the timer
    2. Execute the task
    3. At the end of the task, CLA reads the timer again
    4. Calculate the number of cycles between (1) and (3)

    In C this would look something like:


    ct1 = EPwm1Regs.TBCTR; <<< code to be measured here >>>> ct2 = EPwm1Regs.TBCTR; delta_ct = ct2 - ct1;

    Using a GPIO pin:

    On some devices, the CLA has direct access to GPIO pins.  In this case, instead of reading a timer, the CLA could toggle a pin before and after the code to be measured.  Monitor the pin using an oscilloscope to measure the delta in time.  Refer to the TRM for your specific device.

    Overhead:

    There will be some overhead due to triggering the CLA task and notifying the C28x that it has completed.  In order to test this overhead, you could use a timer on the C28x to time the start and stop of the CLA task. 

    1. Read the timer using the C28x
    2. Start the CLA task via the C28x Software
    3. Wait for the MIRUN bit to clear
    4. Read the timer using the C28x
    5. Calculate the delta between (1) and (4)

    Also refer to the discussion on this post: https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/738758

    Click here for more CLA FAQs and resources.