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.

CCS/TMS320F28379D: TMS320FD28379D

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

I am not able to update the ePwm register from CLA. Both codes below do not work. I have verified that CpySysRegs.SECMSEL.all = 0;

None of the three macros called from *.cla are doing anything. Any help would be much appreciated.

#define ENA_PWM_CLA() __meallow(); \
EPwm1Regs.TZCLR.bit.OST =1;\
EPwm2Regs.TZCLR.bit.OST =1;\
EPwm3Regs.TZCLR.bit.OST =1;\
__medis(); \

#define DIS_PWM_CLA() __meallow(); \
EPwm1Regs.TZFRC.bit.OST =1;\
EPwm2Regs.TZFRC.bit.OST =1;\
EPwm3Regs.TZFRC.bit.OST =1;\
__medis(); \


#define duty_update_CLA(a) \
EPwm1Regs.CMPA.bit.CMPA = (Uint16) (EPWM1_TIMER_TBPRD>>2);\
EPwm2Regs.CMPA.bit.CMPA = (Uint16) (EPWM1_TIMER_TBPRD>>2);\
EPwm3Regs.CMPA.bit.CMPA = (Uint16) (EPWM1_TIMER_TBPRD>>2);\

  • Anup,

    Some things to try in order to pinpoint the problem:

    Confirm that the clock for the ePWM peripherals enabled in the PCLKCR2 register. 

    Try to write to the CMPA register via Code Composer Studio register window in the C28x debug perspective?  Likewise from the CLA debug perspective.  Note: the other two registers will always read back zero. 

    Confirm that the CLA task is getting fired and code has been copied over correctly.  Set a breakpoint in the CLA code and step through the code.  You can observe the disassembly window to see if the code looks reasonable.  You should see mov instructions to the EPwm register address space.

    The CLA hands-on-workshop is very good at describing the CLA, how to develop code for it, and also how to debug it in Code Composer Studio. I think you will find it helpful.

    Here is the link to the CLA workshop:

    Click here for more CLA FAQs and resources.

    Regards,

    Lori

  • Hello Lori,

    I've verified that the epwm module is setup correctly. If I move the epwm register read/write functions over to the main CPU then my full system works as expected. But if I move them to the cla it fails. 

    I am also certain that my CLA code runs because variables are getting updated as expected. I have a three phase phase lock loop code running in the CLA, and I can see the frequency and voltage lock perfectly. So, I am highly confident that the issue lies in the part where CLA tries to update the epwm registers.

    About setting a breakpoint in CLA, I tried that but I think only my CLA is stopped but my main CPU keeps running. Also I am not able to step through the CLA code with disassembly view. Is there a good resource you can point me to for debugging the CLA code, please?

    Anup

  • Anup Thapa said:
    About setting a breakpoint in CLA, I tried that but I think only my CLA is stopped but my main CPU keeps running.

    A trick is you can fire the interrupt from the debugger with the C28x halted.  Or you can fire the task with SW from the C28x and poll for the task to complete before executing more code.  A number of the C2000Ware CLA examples do this. 

    Anup Thapa said:
    Also I am not able to step through the CLA code with disassembly view.

    Does the CLA halt on the breakpoint? What happens when you try to step the CLA code? 

    Anup Thapa said:
    Is there a good resource you can point me to for debugging the CLA code, please?

    Yes, the workshop I mentioned in my previous post is a very good resource.

    Regards

    Lori

  • hello Lori,

    Thanks for the pointer. I went to those links and I went through the workshop. I am able to debug the CLA code and single step through the disassembly. I am able to verify that __meallow(); and __medis() command are working.

    But still no luck with writing to the ePWm registers. Any other suggestions that you can give?

    Thanks

    Anup

  • Further, I am noticing that the executing the follow code only updates the CMPAHR and CMPBHR registers

    (*((Uint16*)(0x406A))) = add_Val0;
    (*((Uint16*)(0x406B))) = add_Val1;
    (*((Uint16*)(0x406C))) = add_Val2;
    (*((Uint16*)(0x406D))) = add_Val3;

    I have add_Val0, Val1, Val2, and Val3 set as 0x100, 0x200, 0x300 and 0x400; 

    After the code is executed, 

    CMPA (add: 0x406A) = No Change

    CMPAHR (add: 0x406B)  = 0x200H

    CMPB (add: 0x406C) = No Change

    CMPBHR (add: 0x406D) = 0x400H

    I find it weird that I cannot update CMPx but only CMPxHR. Does that tell you anything?

  • Anup,

    I think you have the HR and non-HR portions swapped.  See the figure in the technical reference manual titled: HRPWM Extension Registers and Memory Configuration

    Check the resolution of these threads to see if they help:

    https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/358072?Delfino-F28377-PWM-register-write-in-CLA

    https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/464654?TMX320F28075-CLA-PWM-access

    Also note that the HRPWM is not available on CPU2 or CPU2.CLA1.  Are you trying on CPU1 or CPU2 subsystem?

    Regards

    Lori

  • Thanks Lori,

    It's the header files that solved the issue. Although I still need to understand why it solved the issue, solve it did.

    Any pointers to understand the effect of including "F2837xD_Cla_defines.h" and "F2837xD_Cla_typedefs.h" ?

    Anup