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.

TMS320F28379D: CLA example code cannot execute for 20 KHz PWM trigger

Part Number: TMS320F28379D
Other Parts Discussed in Thread: SYSCONFIG

I have followed the C2000 Academy LAB9: Lab - Control Law Accelerator (SysConfig) for the TMS320F28379D. The target board is launchpad. I have done some small modifications:

1- The trigger source for ADCA conversions is set as EPWM1 SOCA.

2- The trigger source for ADCA Interrupt 1 is changed to ADCA EOC3 (We are sampling four inputs and want to trigger interrupt when last input is converted). Also interrupt is registered for ADCA interrupt 1. 

The settings are done as shown below:

The CLA Task 1 is executed successfully (as indicated by blinking of D10 LED) if the EPWM1 frequency is increased to 10 KHz. However if I set the EPWM frequency to 20 KHz then the CLA task execution stops. I have verified that the LED counter only increments once and no more after that. I have tried troubleshooting at my end but unable to understand this behavior. Please guide.

Following are the settings for CLA Task 1:

  • I started the configurations for the EPWM from the scratch and noticed that CLA Task1 is triggered at 20 KHz when only EPWM1 module is added. Then I added EPWM2 (configured on GPIO2/3 of the launchpad) and found that the CLA Task 1 is executing without any issues at 20 KHz. Next I added EPWM3 module (configured on GPIO4/5 of launchpad). This time the CLA Task 1 led stopped blinking. Then I tried reducing the frequency of EPWM1 to 10 KHz to find that the CLA Task1 again executes. So there is something to do with the addition of EPWM3 or maybe any other additional EPWM module. I would request some expert to help me out with this issue. 

  • Hi Asad,

    I will reach out to the expert and let you know.

    Thanks,
    Ashwini

  • Hi Asad,

    Is the blinking LED and LED counter included in CLATask1 on CLA side or CLAIsr1 on C28 side?

    Thanks,
    Ashwini

  • The led blinking is performed in CLAIsr1 on C28 side. In order to confirm that ADCA interrupt is generating at 20 KHz, I registered its interrupt and added another LED toggle. That LED is actually toggling and therefore confirming that ADCA Interrupt is being generated properly. I also modified linker command file to allocate two flash sections for .text section as my code was not fitting into single section. I can share the linker command file content with you tomorrow morning if required.

  • OK thanks Asad. And if I understand correctly, just by removing EPWM3 from the configuration you are seeing the CLAIsr1 LED toggling correctly at 20MHz?

    Thanks,

    Ashwini

  • Your understanding is correct. I can share the Sysconfig file with you or maybe the entire project to check at your end. There is no custom logic in it. I am doing peripherals configurations at this stage. Let me know if this is required.

  • Just to clarify: when EPWM3 is removed then CLAISR1 is called at 20 KHz i.e. same rate as EPWM1. The LED toggles at 1 Hz since I change the LED count check to 20000.

  • Thanks Asad. It would help to understand if there is an issue with LED toggling (could EPWM3 be configuring pins that are allocated for LEd?) or is the CLA1Isr1 not being triggered at all. You mentioned that there is a counter variable that increments inside CLA1isr1 - what value is this showing?

    Thanks,

    Ashwini

  • Actually LEDs are using allocated pins in the launch pad i.e. GPIO 31& GPIO34. Whereas the EPWMs are using their own pins I e GPIO0/GPIO1 for EPWM1, GPIO2/3 for EPWM2, GPIO 4/5 for EPWM3. Furthermore all configurations are done with Sysconfig tool so there should be no resources conflict. I have used the debug mode for investigating the issue and I found that the counter increments once only i.e. its value is changed from 0 to 1 but no further increments. However if I lower the EPWM1 frequency to 10 KHz while keeping the EPWM3 added then led of CLA1Isr1 again starts to toggle. 

  • Actually LEDs are using allocated pins in the launch pad i.e. GPIO 31& GPIO34. Whereas the EPWMs are using their own pins I e GPIO0/GPIO1 for EPWM1, GPIO2/3 for EPWM2, GPIO 4/5 for EPWM3. Furthermore all configurations are done with Sysconfig tool so there should be no resources conflict. I have used the debug mode for investigating the issue and I found that the counter increments once only i.e. its value is changed from 0 to 1 but no further increments. However if I lower the EPWM1 frequency to 10 KHz while keeping the EPWM3 added then led of CLA1Isr1 again starts to toggle. Meaning that CLA1Isr1 is still e to execute but not above 10 kHz. I will review my linker command file today. Maybe something is wrong there. I remember that when I was adding additional peripherals then the code could not fit into the default .text section of the linker command file provided with lab 9 of the C2000 Academy. I had done changes to accommodate large code.

  • After trying all desperate attempts I tried changing the initialization sequence of the peripherals. The Sysconfig Board_init() function initializes the peripherals in the order shown be the following generated code:

    void Board_init()
    {
    	EALLOW;
    
    	PinMux_init();
    	SYNC_init();
    	ADC_init();
    	CLA_init();
    	DAC_init();
    	EPWM_init();
    	GPIO_init();
    	MEMCFG_init();
    	SCI_init();
    	INTERRUPT_init();
    
    	EDIS;
    }

    I was calling this function in the main to configure the peripherals. In order to change the initialization sequence I commented the Board_init function and replaced it with manual function calls in which CLA_init() is moved below EPWM_init(). This is shown in the below code.

    void main(void)
    {
        // Configure system clock and PLL, enable peripherals, and configure
        // flash if used.
        Device_init();
    
        // Initialize the PIE module and vector table.
        Interrupt_initModule();
        Interrupt_initVectorTable();
    
        //Board_init();
        EALLOW;
    
            PinMux_init();
            SYNC_init();
            ADC_init();
            DAC_init();
            EPWM_init();
            CLA_init();
            GPIO_init();
            MEMCFG_init();
            SCI_init();
            INTERRUPT_init();
    
        EDIS;
    
        // Enable global interrupts.
        EINT;
        // Enable real-time debug.
        ERTM;
    
        for (;;)
        {
            // Do nothing.
            DEVICE_DELAY_US(100);
            // Force task 8 to run to perform init routines.
            //CLA_forceTasks(CLA1_BASE, CLA_TASKFLAG_8);
            NOP;
        }
    }
    

    This change of order fixes the issue. We can close the ticket but it will be nice if some expert can elaborate on this and maybe there can be some improvement incorporated to Sysconfig code generation tool based on the findings of this thread. It should be noted that Sysconfig tool is used for configuring all the peripherals.

  • Hi,

    Last year, TI released Academy style online training on C2000 devices. The objective of the training is to provide step-by-step guidance to get started with C2000 family of real-time MCU. We know you have looked at C2000 Academy for CLA modules. We want to reach out to you if you can share your experience with Academy. Do you have any feedback/suggestion to improve it? We are contently looking for ways to improve the content so that it is more useful to the customer, so any feedback/suggestion will be really helpful.

     

    Thank you so much for taking the time to provide your feedback.

     

    Thanks & Regards,

    Santosh Jha

  • The C2000 Academy is an excellent resource for those starting with the the C2000 devices and has been very helpful to me. I have more than 10 years of  firmware development experience in different applications but recently shifted to the TIs C2000 series as these appear to be more suitable for the real time control of digital power converters. From my experience I find that the advanced peripherals have very detailed technical literatures and complex settings requirement. The automated code generation tools are very helpful in this case as these have lot of built in checks to warn the developer for any inconsistencies. Moreover automated tools also help in easy code migration from one target controller to another especially from a development board to production boards. 

    For improvement suggestions: The contents appear to be more focused on driver library approach. I would suggest to make these more Sysconfig oriented for the reason mentioned ahead.

    Thank you very much TI E2E for continuous help and support during our project development.

  • Asad,

    Thank you so much for the feedback. We are slowly adding more content on SysConfig based configuration.

    With Best Regards,

    Santosh