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.

LAUNCHXL-F280039C: GPIO output could not be toggled when used in .cla file

Part Number: LAUNCHXL-F280039C
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hello Experts,

Condition:-

I am trying to toggle GPIO22 (LED5 on the Launch Pad - LAUNCHXL-F280039C) using CLA.

I have imported the given example project - "cla_ex4_pwm_control", which is available on the resource explorer

In the example project, I have made a few additions to configure GPIO22 (main.c) and tried to toggle the GPIO in the .cla file, but it is not working (toggling)

Question:-

I can see that the duty of EPWM varies, which ensures that the CLA task is executing; however, the GPIO does not toggle, which is present within the same CLA task.

main.c

//
// Included Files
//
#include <cla_ex4_pwm_control_shared.h>
#include "driverlib.h"
#include "device.h"
#include "board.h"

//
// Function Prototypes
//
void initEPWM(void);
void initCLA(void);

//
// Main
//
void main(void)
{
    //
    // Initialize device clock and peripherals
    //
    Device_init();

    //
    // Disable pin locks and enable internal pullups.
    //
    Device_initGPIO();

    //
    // GPIO0 is set to EPWM1A
    // GPIO1 is set to EPWM1B
    //
    GPIO_setControllerCore(0, GPIO_CORE_CPU1);
    GPIO_setPadConfig(0,GPIO_PIN_TYPE_STD);
    GPIO_setPinConfig(GPIO_0_EPWM1_A);
    GPIO_setControllerCore(1, GPIO_CORE_CPU1);
    GPIO_setPadConfig(1,GPIO_PIN_TYPE_STD);
    GPIO_setPinConfig(GPIO_1_EPWM1_B);

    // Adding GPIO22 for toggle
    GPIO_setAnalogMode(22,GPIO_ANALOG_DISABLED);
    GPIO_setDirectionMode(22,GPIO_DIR_MODE_OUT);
    GPIO_setQualificationMode(22,GPIO_QUAL_SYNC);
    GPIO_setPinConfig(GPIO_22_GPIO22);
    GPIO_setMasterCore(22, GPIO_CORE_CPU1_CLA1);

    //
    // Initialize PIE and clear PIE registers. Disables CPU interrupts.
    //
    Interrupt_initModule();

    //
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    //
    Interrupt_initVectorTable();

    //
    // Disable sync(Freeze clock to PWM as well)
    //
    SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);

    //
    // Initialize EPWM module
    //
    initEPWM();

    //
    // Initialize resources
    //
    Board_init();
    initCLA();

    //
    // Enable global interrupts.
    //
    EINT;

    //
    // Enable sync and clock to PWM
    //
    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);

    for(;;)
    {

    }
}


//
// EPWM Initialization
// EPWM1 : generates output of frequency EPWM1_FREQ (100 KHz)
// EPWM4 : Triggers CLA task at frequency EPWM4_FREQ (10 KHz)
//
void initEPWM(void)
{
    //
    // Set up EPWM1 to
    // - run on a base clock of SYSCLK
    // - have a period of EPWM1_PERIOD
    // - run in count up-down mode
    //
    EPWM_setClockPrescaler(EPWM1_BASE, EPWM_CLOCK_DIVIDER_1,
                           EPWM_HSCLOCK_DIVIDER_1);
    EPWM_setTimeBasePeriod(EPWM1_BASE, EPWM1_PERIOD);
    EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, EPWM1_PERIOD/10U);
    EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP_DOWN);
    EPWM_setTimeBaseCounter(EPWM1_BASE, 0U);

    //
    // Configuring action-qualifiers for EPWM1 to generate symmetric
    // and complementary outputs on channel A and B
    //
    EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A,
                         EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
    EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A,
                             EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
    EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_B,
                             EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
    EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_B,
                             EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);

    //
    // Enabling Counter Compare shadow mode
    //
    EPWM_setCounterCompareShadowLoadMode(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_SYNC_CNTR_ZERO);

    //
    // Set up EPWM4 to
    // - run on a base clock of SYSCLK
    // - have a period of EPWM4_PERIOD
    // - run in count up mode
    EPWM_setClockPrescaler(EPWM4_BASE, EPWM_CLOCK_DIVIDER_1,
                           EPWM_HSCLOCK_DIVIDER_1);
    EPWM_setTimeBasePeriod(EPWM4_BASE, EPWM4_PERIOD);
    EPWM_setTimeBaseCounterMode(EPWM4_BASE, EPWM_COUNTER_MODE_UP);
    EPWM_setTimeBaseCounter(EPWM4_BASE, 0U);

    //
    // Enabling EPWM4 interrupt at TBCTR = 0 to trigger
    // CLA task
    //
    EPWM_setInterruptSource(EPWM4_BASE, EPWM_INT_TBCTR_ZERO);
    EPWM_enableInterrupt(EPWM4_BASE);
    EPWM_setInterruptEventCount(EPWM4_BASE, 1U);

    //
    // EPWM 1 and 4 should run freely in emulation mode
    //
    EPWM_setEmulationMode(EPWM1_BASE, EPWM_EMULATION_FREE_RUN);
    EPWM_setEmulationMode(EPWM4_BASE, EPWM_EMULATION_FREE_RUN);
}

//
// CLA Initialization
//
void initCLA(void)
{
    //
    // Force task 8, the one time initialization task
    //
    CLA_forceTasks(CLA1_BASE, CLA_TASKFLAG_8);
}


.cla

//#############################################################################
//
// FILE:   cla_ex4_pwm_control_cla.cla
//
// TITLE:  Controlling PWM output using CLA
//
// Task 8 initializes the global variables for CLA
//
// Task 1 implements control logic to update duty value of PWM output
//
//#############################################################################
//
//
// $Copyright:
// Copyright (C) 2025 Texas Instruments Incorporated - http://www.ti.com/
//
// Redistribution and use in source and binary forms, with or without 
// modification, are permitted provided that the following conditions 
// are met:
// 
//   Redistributions of source code must retain the above copyright 
//   notice, this list of conditions and the following disclaimer.
// 
//   Redistributions in binary form must reproduce the above copyright
//   notice, this list of conditions and the following disclaimer in the 
//   documentation and/or other materials provided with the   
//   distribution.
// 
//   Neither the name of Texas Instruments Incorporated nor the names of
//   its contributors may be used to endorse or promote products derived
//   from this software without specific prior written permission.
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################

//
// Included Files
//
#include <cla_ex4_pwm_control_shared.h>
#include <stdint.h>
#include "epwm.h"

#include "driverlib.h"
#include "device.h"
#include "board.h"



//
// Globals
//
// Note that the globals defined in the .cla source are global to the cla source
// file.  i.e. they may be shared across tasks. But they cannot be assigned an
// initialized value here. To do so, one-time initialization task is used that
// is triggered by software at the beginning
//
// Duty value
float duty ;

//-----------------------------------------------------------------------------
//
// Task 1 - PWM control loop
//
// Description: PWM control logic can be implemented here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt)) void Cla1Task1 ( void )
{
    HWREG(GPIODATA_BASE + GPIO_O_GPASET ) = 0x00400000UL;
    //GPIO_writePin(22,0);
    //
    // 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;

//    volatile uint32_t i;
//    for (i = 0; i < 20000000; i++)
//    {
//        // Empty loop for delay
//    }
//    volatile uint32_t j;
//    for (j = 0; j < 20000000; j++)
//    {
//        // Empty loop for delay
//    }
//    volatile uint32_t k;
//    for (k = 0; k < 20000000; k++)
//    {
//        // Empty loop for delay
//    }


    HWREG(GPIODATA_BASE + GPIO_O_GPACLEAR ) = 0x00400000UL;
    //GPIO_writePin(22,1);

    //
    // Clear EPWM4 interrupt flag so that next interrupt can come in
    //
    EPWM_clearEventTriggerInterruptFlag(EPWM4_BASE);
}

//-----------------------------------------------------------------------------
//
// Task 2 - Title Here
//
// Description: Description/steps here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt))  void Cla1Task2 ( void )
{

}

//-----------------------------------------------------------------------------
//
// Task 3 - Title Here
//
// Description: Description/steps here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt))  void Cla1Task3 ( void )
{

}

//-----------------------------------------------------------------------------
//
// Task 4 - Title Here
//
// Description: Description/steps here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt))  void Cla1Task4 ( void )
{

}

//-----------------------------------------------------------------------------
//
// Task 5 - Title Here
//
// Description: Description/steps here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt))  void Cla1Task5 ( void )
{

}

//-----------------------------------------------------------------------------
//
// Task 6 - Title Here
//
// Description: Description/steps here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt))  void Cla1Task6 ( void )
{

}

//-----------------------------------------------------------------------------
//
// Task 7 - Title Here
//
// Description: Description/steps here.
//
//-----------------------------------------------------------------------------
__attribute__((interrupt))  void Cla1Task7 ( void )
{

}

//-----------------------------------------------------------------------------
//
// Task 8 - One Time Initialization Task
//
// Description: This task will initialize the CLA global variables
//
//-----------------------------------------------------------------------------
__attribute__((interrupt))  void Cla1Task8 ( void )
{
    //
    // Uncomment this to debug the CLA while connected to the debugger
    //
    //__mdebugstop();

    duty = 0.1f;
}

//
// End of File
//

  • Hello,

    This behavior is expected, the CLA cannot directly access GPIO registers using CPU memory-mapped addresses unless the GPIO register region is explicitly marked as CLA-accessible.

    In your CLA task:

    HWREG(GPIODATA_BASE + GPIO_O_GPASET) = 0x00400000UL;

    and

    HWREG(GPIODATA_BASE + GPIO_O_GPACLEAR) = 0x00400000UL;

    These addresses refer to CPU-accessible peripheral memory space, but by default the CLA cannot access peripheral registers directly.

    Only memory regions that you explicitly mark as CLA-accessible (via CLA memory mapping or message RAM) are visible to the CLA. There are two main ways to make the LED toggle work. Let the CLA set a flag variable (in shared RAM), and have the CPU poll that variable in its main loop and toggle the GPIO. In cla_ex4_pwm_control_shared.h

    extern volatile uint16_t cla_toggle_flag;

    In main.c

    #pragma DATA_SECTION(cla_toggle_flag, "Cla1ToCpuMsgRAM");
    volatile uint16_t cla_toggle_flag = 0;
    
    void main(void)
    {
    ...
    for(;;)
    {
    if (cla_toggle_flag == 1)
    {
    GPIO_togglePin(22);
    cla_toggle_flag = 0;
    }
    }
    }

    In .cla file

    #pragma DATA_SECTION(cla_toggle_flag, "Cla1ToCpuMsgRAM");
    volatile uint16_t cla_toggle_flag;
    
    __attribute__((interrupt)) void Cla1Task1(void)
    {
    cla_toggle_flag = 1;
    ...
    }

    This ensures that the CLA communicates through message RAM, which both the CLA and CPU can access safely.

    Second option, if you really want the CLA to manipulate GPIO directly, you must enable CLA access to peripheral registers (GPIO module). Add this before enabling tasks:

    CLA_mapPeripheralToCLA(CLA1_BASE, CLA_PERIPHERAL_GPIOA);

    Then use the CLA driverlib API:

    CLA_writeGPIOPin(22, 1); // or toggle

    However, note that GPIO toggling is generally not recommended from CLA, because it’s slower due to the bus arbitration. The CLA is meant for real-time math/control, not I/O handling.

    Best Regards,

    Masoud

  • Thank you, Masoud. This is really helpful

    I understand that GPIO toggling is generally not recommended from a CLA perspective. I am in a learning phase to understand CLA. This is the reason I chose GPIO Toggling

    Again, back to my question..

    I don't know how, but I can toggle GPIO in the given example project - "cla_ex4_pwm_control"

    main.c

    //
    // Included Files
    //
    #include <cla_ex4_pwm_control_shared.h>
    #include "driverlib.h"
    #include "device.h"
    #include "board.h"
    
    //
    // Function Prototypes
    //
    void initEPWM(void);
    void initCLA(void);
    
    #pragma SET_DATA_SECTION("cla_shared")
    
    volatile reference ref_data = {35,35,0}; // Target digital values for loops
    
    #pragma SET_DATA_SECTION()   // Reset section to default
    
    //
    // Main
    //
    void main(void)
    {
        //
        // Initialize device clock and peripherals
        //
        Device_init();
    
        //
        // Disable pin locks and enable internal pullups.
        //
        Device_initGPIO();
    
        //
        // GPIO0 is set to EPWM1A
        // GPIO1 is set to EPWM1B
        //
    //    GPIO_setControllerCore(0, GPIO_CORE_CPU1);
    //    GPIO_setPadConfig(0,GPIO_PIN_TYPE_STD);
    //    GPIO_setPinConfig(GPIO_0_EPWM1_A);
    //    GPIO_setControllerCore(1, GPIO_CORE_CPU1);
    //    GPIO_setPadConfig(1,GPIO_PIN_TYPE_STD);
    //    GPIO_setPinConfig(GPIO_1_EPWM1_B);
    
        // Adding GPIO22 for toggle
    //    GPIO_setDirectionMode(22, GPIO_DIR_MODE_OUT);
    //    GPIO_setQualificationMode(22, GPIO_QUAL_SYNC);
    //    GPIO_setPinConfig(GPIO_22_GPIO22); // Use correct pinmux macro
    //    GPIO_setControllerCore(22, GPIO_CORE_CPU1_CLA1); // Assign CLA as controller
    
    //    GPIO_setDirectionMode(14, GPIO_DIR_MODE_OUT);
    //    GPIO_setQualificationMode(14, GPIO_QUAL_SYNC);
    //    GPIO_setPinConfig(GPIO_14_GPIO14); // Use correct pinmux macro
    //    GPIO_setControllerCore(14, GPIO_CORE_CPU1_CLA1); // Assign CLA as controller
    
    
        //
        // Initialize PIE and clear PIE registers. Disables CPU interrupts.
        //
        Interrupt_initModule();
    
        //
        // Initialize the PIE vector table with pointers to the shell Interrupt
        // Service Routines (ISR).
        //
        Interrupt_initVectorTable();
    
        //
        // Disable sync(Freeze clock to PWM as well)
        //
        SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
    
        //
        // Initialize EPWM module
        //
        initEPWM();
    
        //
        // Initialize resources
        //
        Board_init();
        //initCLA();
    
        //
        // Enable global interrupts.
        //
        EINT;
    
        //
        // Enable sync and clock to PWM
        //
        SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
    
        for(;;)
        {
    
        }
    }
    
    
    //
    // EPWM Initialization
    // EPWM1 : generates output of frequency EPWM1_FREQ (100 KHz)
    // EPWM4 : Triggers CLA task at frequency EPWM4_FREQ (10 KHz)
    //
    void initEPWM(void)
    {
        //
        // Set up EPWM1 to
        // - run on a base clock of SYSCLK
        // - have a period of EPWM1_PERIOD
        // - run in count up-down mode
        //
    //    EPWM_setClockPrescaler(EPWM1_BASE, EPWM_CLOCK_DIVIDER_1,
    //                           EPWM_HSCLOCK_DIVIDER_1);
    //    EPWM_setTimeBasePeriod(EPWM1_BASE, EPWM1_PERIOD);
    //    EPWM_setCounterCompareValue(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, EPWM1_PERIOD/10U);
    //    EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP_DOWN);
    //    EPWM_setTimeBaseCounter(EPWM1_BASE, 0U);
    //
    //    //
    //    // Configuring action-qualifiers for EPWM1 to generate symmetric
    //    // and complementary outputs on channel A and B
    //    //
    //    EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A,
    //                         EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
    //    EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_A,
    //                             EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
    //    EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_B,
    //                             EPWM_AQ_OUTPUT_HIGH, EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
    //    EPWM_setActionQualifierAction(EPWM1_BASE, EPWM_AQ_OUTPUT_B,
    //                             EPWM_AQ_OUTPUT_LOW, EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
    //
    //    //
    //    // Enabling Counter Compare shadow mode
    //    //
    //    EPWM_setCounterCompareShadowLoadMode(EPWM1_BASE, EPWM_COUNTER_COMPARE_A, EPWM_COMP_LOAD_ON_SYNC_CNTR_ZERO);
    
        //
        // Set up EPWM4 to
        // - run on a base clock of SYSCLK
        // - have a period of EPWM4_PERIOD
        // - run in count up mode
        EPWM_setClockPrescaler(EPWM4_BASE, EPWM_CLOCK_DIVIDER_1,
                               EPWM_HSCLOCK_DIVIDER_1);
        EPWM_setTimeBasePeriod(EPWM4_BASE, EPWM4_PERIOD);
        EPWM_setTimeBaseCounterMode(EPWM4_BASE, EPWM_COUNTER_MODE_UP);
        EPWM_setTimeBaseCounter(EPWM4_BASE, 0U);
    
        //
        // Enabling EPWM4 interrupt at TBCTR = 0 to trigger
        // CLA task
        //
        EPWM_setInterruptSource(EPWM4_BASE, EPWM_INT_TBCTR_ZERO);
        EPWM_enableInterrupt(EPWM4_BASE);
        EPWM_setInterruptEventCount(EPWM4_BASE, 1U);
    
        //
        // EPWM 1 and 4 should run freely in emulation mode
        //
        //EPWM_setEmulationMode(EPWM1_BASE, EPWM_EMULATION_FREE_RUN);
        EPWM_setEmulationMode(EPWM4_BASE, EPWM_EMULATION_FREE_RUN);
    }
    
    //
    // CLA Initialization
    //
    void initCLA(void)
    {
        //
        // Force task 8, the one time initialization task
        //
        CLA_forceTasks(CLA1_BASE, CLA_TASKFLAG_8);
    }

    .cla

    //
    // Included Files
    //
    #include <cla_ex4_pwm_control_shared.h>
    #include <stdint.h>
    #include "epwm.h"
    
    #include "driverlib.h"
    #include "device.h"
    #include "board.h"
    
    
    
    //
    // Globals
    //
    // Note that the globals defined in the .cla source are global to the cla source
    // file.  i.e. they may be shared across tasks. But they cannot be assigned an
    // initialized value here. To do so, one-time initialization task is used that
    // is triggered by software at the beginning
    //
    // Duty value
    float duty ;
    
    //-----------------------------------------------------------------------------
    //
    // Task 1 - PWM control loop
    //
    // Description: PWM control logic can be implemented here.
    //
    //-----------------------------------------------------------------------------
    __attribute__((interrupt)) void Cla1Task1 ( void )
    {
        //HWREG(GPIODATA_BASE + GPIO_O_GPASET) = (1 << 22);   // Set GPIO22
        //HWREG(GPIODATA_BASE + GPIO_O_GPASET ) = 0x00400000UL;
        //GPIO_writePin(14,1);
        //
        // 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;
    
    //    volatile uint32_t i;
    //    for (i = 0; i < 20000000; i++)
    //    {
    //        // Empty loop for delay
    //    }
    //    volatile uint32_t j;
    //    for (j = 0; j < 20000000; j++)
    //    {
    //        // Empty loop for delay
    //    }
    //    volatile uint32_t k;
    //    for (k = 0; k < 20000000; k++)
    //    {
    //        // Empty loop for delay
    //    }
    
    
        //HWREG(GPIODATA_BASE + GPIO_O_GPACLEAR ) = 0x00400000UL;
        //GPIO_writePin(14,0);
        //HWREG(GPIODATA_BASE + GPIO_O_GPACLEAR) = (1 << 22); // Clear GPI
        GPIO_togglePin(LED0);
        loop1_task();
        //
        // Clear EPWM4 interrupt flag so that next interrupt can come in
        //
        EPWM_clearEventTriggerInterruptFlag(EPWM4_BASE);
    }
    
    //-----------------------------------------------------------------------------
    //
    // Task 2 - Title Here
    //
    // Description: Description/steps here.
    //
    //-----------------------------------------------------------------------------
    __attribute__((interrupt))  void Cla1Task2 ( void )
    {
    
    }
    
    //-----------------------------------------------------------------------------
    //
    // Task 3 - Title Here
    //
    // Description: Description/steps here.
    //
    //-----------------------------------------------------------------------------
    __attribute__((interrupt))  void Cla1Task3 ( void )
    {
    
    }
    
    //-----------------------------------------------------------------------------
    //
    // Task 4 - Title Here
    //
    // Description: Description/steps here.
    //
    //-----------------------------------------------------------------------------
    __attribute__((interrupt))  void Cla1Task4 ( void )
    {
    
    }
    
    //-----------------------------------------------------------------------------
    //
    // Task 5 - Title Here
    //
    // Description: Description/steps here.
    //
    //-----------------------------------------------------------------------------
    __attribute__((interrupt))  void Cla1Task5 ( void )
    {
    
    }
    
    //-----------------------------------------------------------------------------
    //
    // Task 6 - Title Here
    //
    // Description: Description/steps here.
    //
    //-----------------------------------------------------------------------------
    __attribute__((interrupt))  void Cla1Task6 ( void )
    {
    
    }
    
    //-----------------------------------------------------------------------------
    //
    // Task 7 - Title Here
    //
    // Description: Description/steps here.
    //
    //-----------------------------------------------------------------------------
    __attribute__((interrupt))  void Cla1Task7 ( void )
    {
    
    }
    
    //-----------------------------------------------------------------------------
    //
    // Task 8 - One Time Initialization Task
    //
    // Description: This task will initialize the CLA global variables
    //
    //-----------------------------------------------------------------------------
    __attribute__((interrupt))  void Cla1Task8 ( void )
    {
        //
        // Uncomment this to debug the CLA while connected to the debugger
        //
        //__mdebugstop();
    
        //duty = 0.1f;
    }

    shared.cla

    #ifndef _CLA_EX4_PWMCONTROL_SHARED_H_
    #define _CLA_EX4_PWMCONTROL_SHARED_H_
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    //
    // Included Files
    //
    #include "driverlib.h"
    #include "device.h"
    
    //
    // Defines
    //
    #define EPWM1_FREQ          100000UL   // 100 KHz
    #define EPWM4_FREQ          10000UL    // 10 KHz
    //#define EPWM1_FREQ          10000UL   // 10 KHz
    //#define EPWM4_FREQ          1UL    // 1 Hz
    
    #define EPWM1_PERIOD        (uint16_t)(DEVICE_SYSCLK_FREQ / (2 * EPWM1_FREQ))
    #define EPWM4_PERIOD        (uint16_t)(DEVICE_SYSCLK_FREQ / EPWM4_FREQ)
    
    typedef struct {
        uint16_t loop1;
        uint16_t loop2;
        uint16_t result;
    }reference;
    
    extern volatile reference ref_data;
    
    //
    // Loop1 control task defined in a shared file so that can be used both
    // by CPU and CLA in order avoid code duplication
    //
    static inline void loop1_task(void)
    {
        ref_data.result = ref_data.loop1 + ref_data.loop2;
    }
    
    //
    // Globals
    //
    //Task 1 (C) Variables
    extern float duty;
    
    //Task 2 (C) Variables
    
    //Task 3 (C) Variables
    
    //Task 4 (C) Variables
    
    //Task 5 (C) Variables
    
    //Task 6 (C) Variables
    
    //Task 7 (C) Variables
    
    //Task 8 (C) Variables
    
    //Common (C) Variables
    
    
    //
    // Function Prototypes
    //
    __attribute__((interrupt))  void Cla1Task1();
    __attribute__((interrupt))  void Cla1Task2();
    __attribute__((interrupt))  void Cla1Task3();
    __attribute__((interrupt))  void Cla1Task4();
    __attribute__((interrupt))  void Cla1Task5();
    __attribute__((interrupt))  void Cla1Task6();
    __attribute__((interrupt))  void Cla1Task7();
    __attribute__((interrupt))  void Cla1Task8();
    
    #ifdef __cplusplus
    }
    #endif // extern "C"
    #endif //_CLA_EX4_PWMCONTROL_SHARED_H_

          

    Question:

    As per your guidance, there are 2 ways to toggle the GPIO

    1. Set a CLA flag variable (in shared RAM), and have the CPU poll that variable in its main loop and toggle the GPIO. In cla_ex4_pwm_control_shared.h

    2. CLA to manipulate GPIO directly, must enable CLA access to peripheral registers (GPIO module)

    Option 1 is not used in the example code above. It might be that option 2 is used to toggle the GPIO

    Please share details, do the example projects already enable CLA access to peripheral registers (GPIO module)

    If yes, where can I find the registers that enabled CLA access to peripheral registers in example projects

    Please note: In the above example project, I have used GPIO_14, which is configured using sysconfig

    "Apologizing in advance if my question is really silly, I am still in a learning stage."

  • Hello Vishal,

    Here is the CLA access table. You can check the GPIO registers that CLA has access to:

    For GPIOs, we need to assign ownership to CPU1'S CLA1, which I see you have done in the sysconfig file.

    Best Regards,

    Masoud