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.

TMS320F28069: Clockcycles between two interrupt calls

Part Number: TMS320F28069
Other Parts Discussed in Thread: C2000WARE

Hi

I want to know how to calculate available clockcycles between two interrupt calls.
For example, lets say i have a 100kHz pwm interrupt running. When configure the PWM module for upcount mode, we calculate the  TBPRD value using 90000000 / 100000 = 900.
Is that means i only have 900 clock cycles between two pwm calls.?

Best regards
Damith

  • Damith,

    You have a total of 900 cycles between the interrupts, yes. But that doesn't take into account context store and restore. If you are looking specifically for the amount of time to execute your main program don't forget to take into account the amount of time spent in an ISR as well.

    Regards,
    Cody 

  • Hi cody

    Thank you for the response.

    Im sorry but i didnt get what you said. Im new to this area. Can you please elaborate further.

    Regards

    Damith

  • Damith, 

    an interrupt effectively pulls the processor away from the main task to "service an interrupt" which is typically a small piece of time-sensitive code. This is unrelated to the main code so the CPU's working registers must be saved before the interrupt is executed and restored to their previous value after the interrupt is completed. This takes a tens of cycles for store and restore, and should be well documented. https://software-dl.ti.com/C2000/docs/c28x_context_save_restore/html/index.html 

    Furthermore, my point about the main code/ ISR(interrupt service routine or sometimes just called an Interrupt) code was that you typically need to do more than one thing between each ISR call, so your clock cycles will be further divided.

    The F28069 processor is quite powerful for many applications. And don't over look the CLA, it can act independently of the CPU and can effectively double your clock cycles between your ISR calls. But if you simply need more clock speed or more cores there are many other C2000 devices available. https://www.ti.com/microcontrollers-mcus-processors/microcontrollers/c2000-real-time-control-mcus/products.html#p3164=180;925 

    Regards,
    Cody 

  • Dear Cody

    Thank you very much for the detailed explanation. It is really helpful.
    Now let me explain my actual problem.
    I am trying to run a control loop for an inverter at 100kHz speed. Im going to use the 100kHz pwm interrupt for this.

    For this project, i use following c2000ware libraries.

    Sogi_PLL_1PH library.
    Sine analyzer library
    Digital Control library.
    RampGen library

    From these libraries, i use two SPLL_1PH_SOGI_run s , four DCL_runPID_C s, one sine analyzer function and one rampgen function.  apart from that, one sinf and cosf functions are running.
    All these were included in 100kHz interrupt.
    Code runs fine without the SPLL functions, but as soon as i inserted the SPLL to code, it stops running.
    I guessing i am running out clock cycles to do this in a single run.

    According to your answer, i can use CLA to effectively double the clock cycles. I never used CLA before.
    SO i want to know more about it.

    Algorithm i use should run above function in a single run sequentially at 100kHz.
    CLA runs as a kind of a separate CPU, right?.,
    So if i want to transfer some of the load to CLA, what is the best way to transfer it keeping the sequential behavior intact.


    Apart from that, Can you please suggest a way to calculate the clock cycles consumed by the functions i used in the code.

    Regards
    Damith

  • The easiest way to observe clock cycles is to preform GPIO toggles as certain points in your code. Then measure the time with an oscilloscope.

    The CLA is a second core, typically people will off load certain tasks to it. I believe somethings in the digital control library are actually written to run on the C28x core or the CLA core. CLA guide https://software-dl.ti.com/C2000/docs/cla_software_dev_guide/index.html 

    Using the GPIO toggles you should see if you are over running your ISR. Additionally there is a flag which indicates if an interrupt overflows. Meaning that the Device tries to set the IFR flag, but the IFR flag is already set. I would recommend checking that flag too.

    Regards,
    Cody 

  • Hi Cody

    Thank you. Can i know the cycle count for GPIO toggle.

    Regards
    Damith