SPRACS0A May   2020  – November 2022 TMS320F280048-Q1 , TMS320F280048C-Q1 , TMS320F280049 , TMS320F280049-Q1 , TMS320F280049C , TMS320F280049C-Q1 , TMS320F28033 , TMS320F28033-Q1 , TMS320F28035 , TMS320F28035-EP , TMS320F28035-Q1 , TMS320F28053 , TMS320F28055 , TMS320F2806-Q1 , TMS320F28065 , TMS320F28069 , TMS320F28069-Q1 , TMS320F28069F , TMS320F28069F-Q1 , TMS320F28069M , TMS320F28069M-Q1 , TMS320F28075 , TMS320F28075-Q1 , TMS320F28076 , TMS320F28374D , TMS320F28374S , TMS320F28375D , TMS320F28375S , TMS320F28375S-Q1 , TMS320F28376D , TMS320F28376S , TMS320F28377D , TMS320F28377D-EP , TMS320F28377D-Q1 , TMS320F28377S , TMS320F28377S-Q1 , TMS320F28378D , TMS320F28378S , TMS320F28379D , TMS320F28379D-Q1 , TMS320F28379S , TMS320F28384D , TMS320F28384D-Q1 , TMS320F28384S , TMS320F28384S-Q1 , TMS320F28386D , TMS320F28386D-Q1 , TMS320F28386S , TMS320F28386S-Q1 , TMS320F28388D , TMS320F28388S , TMS320F28P650DH , TMS320F28P650DK , TMS320F28P650SH , TMS320F28P650SK , TMS320F28P659DK-Q1

 

  1.   Software Examples to Showcase Unique Capabilities of TI’s C2000 CLA
  2.   Trademarks
  3. 1Introduction
  4. 2Direct Access of CLA to Key Peripherals
  5. 3Low interrupt Latency of CLA
  6. 4Powerful Math Computation Capability of CLA
  7. 5Offloading Fast Control Loop to CLA
    1. 5.1 Handling Shared Resources Across C28x/CLA
  8. 6Summary
  9. 7References
  10. 8Revision History

Direct Access of CLA to Key Peripherals

Most of the real-time control algorithms can be split into three main tasks: excite the system, sample the system and control the system. Exciting the system would involve updating the PWM registers, sampling the system involves accessing the ADC result registers while controlling the system involves control loop math computations. CLA being an independent math processor, also has the ability to access registers of all key peripherals used for control applications like EPWM, ADC, ECAP, EQEP, CMPSS, and so forth directly. This allows CLA to perform sampling and actuation along with computation of control logic and is capable of executing the entire control task independently without any C28x involvement.

The example “cla_ex4_pwm_control” showcases how to control the PWM signal output directly through CLA. The block diagram of this example is shown in Figure 2-1. In this example, EPWM1 is configured to generate complementary signals on both of its channels at a fixed frequency of 100 KHz while EPWM4 is configured to trigger a periodic CLA control task at a frequency of 10 KHz. The CLA Task 1 implements a very simple logic to vary the duty of the EPWM1 outputs by increasing it by 0.1 for every iteration while maintaining it in the range of 0.1-0.9. The code sequence below illustrates how the existing C28x driverlib APIs (available as part of C2000Ware) can be used as it is within the CLA task to update the EPWM registers avoiding any additional software development effort with respect to CLA. The CLA task can access key registers of other shared peripherals as well in a similar fashion. Note that the CLA global variables cannot be initialized at the start of .cla file thus this example also illustrates a systematic way of initializing all the CLA global variables inside a dedicated CLA task (CLA task 8), which is triggered by C28x software at the time of initialization.

GUID-48ABA0D3-284A-4AEE-BC88-91C089DBB139-low.gifFigure 2-1 Direct PWM Control Using CLA
__attribute__((interrupt)) void Cla1Task1 ( void )
{
    //
    // Uncomment this to debug the CLA while connected to the debugger
    //
    __mdebugstop();
    //
    // Write to the COMPA register to realize a particular duty value
    //
    EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A,
                                (uint16_t)(duty * EPWM1_PERIOD + 0.5f));
    
    //
    // Update duty value and use the limiter
    //
    duty += 0.1f;
    duty = (duty > 0.9f) ? 0.1f : duty;
    //
    // Clear EPWM4 interrupt flag so that next interrupt can come in
    //
    EPWM_clearEventTriggerInterruptFlag(EPWM4_BASE);
}