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: EXTSYNCIN2 for pwm4

Part Number: TMS320F28379D

Tool/software: Code Composer Studio

Hi,

    Sorry I thought my question has been resolved, but actually there is still a minor problem.

    I can use EXTSYNCIN1 which is XBAR5 on GPIO19 to trigger PWM1, but I cannot use EXTSYNCIN2 which is XBAR6 on GPIO18 to trigger PWM4

    Below is my code

    

    InputXbarRegs.INPUT5SELECT = 19;
    GPIO_SetupPinOptions(19, GPIO_INPUT, GPIO_PULLUP);
    InputXbarRegs.INPUT6SELECT = 18;
    GPIO_SetupPinOptions(18, GPIO_INPUT, GPIO_INVERT);

    EPwm4Regs.TBCTL.bit.SYNCOSEL = 0;

    EPwm4Regs.TBCTL.bit.PHSEN = 1;

    EALLOW;
    CpuSysRegs.PCLKCR0.bit.TBCLKSYNC =1;
    SyncSocRegs.SYNCSELECT.bit.EPWM4SYNCIN = 6;
    EDIS;

    If I change EPWM4SYNCIN bit value to 5, then it can be triggered by EXTSYNCIN1, but writing 6 cannot use EXTSYNCIN2  to trigger.

    Can you help check where is the problem? Thanks

  • Hi,

        I did some debug. What I found is if I keep all the other code same, and only change this line, then one can work, one cannot work.

        I am using empty_bitfield_driverlib so I can use both bit-setting or driverlib.

    XBAR_setInputPin(XBAR_INPUT6, 18);       // this can work, pwm4 will sync to EXTSYNCIN2


    InputXbarRegs.INPUT6SELECT = 18;         // this cannot work, pwm4 will not sync to EXTSYNCIN2, it seems it will sync to pwm1

        Can you help check why is that? Thanks 

        

  • EALLOW?

    Check the definition of the XBAR_setInputPin.

  • Hi,

        EALLOW is both used in these cases. I tried to look at the XBAR_setInputPin function

    XBAR_setInputPin(XBAR_InputNum input, uint16_t pin)
    {
    //
    // Check the argument.
    //
    ASSERT(pin <= XBAR_GPIO_MAX_CNT);

    //
    // Write the requested pin to the appropriate input select register.
    //
    EALLOW;

    HWREGH(XBAR_INPUT_BASE + (uint16_t)input) = pin;

    EDIS;
    }

        Then for HWREGH

    #define HWREGH(x) \
    (*((volatile uint16_t *)((uintptr_t)(x))))

        I cannot understand HWREGH when tracing. 

  • Hi,

        I have found the problem. In my code I use this which is ok:

    EALLOW;

    XBAR_setInputPin(XBAR_INPUT5, 19);
    GPIO_SetupPinOptions(19, GPIO_INPUT, GPIO_PULLUP);
    XBAR_setInputPin(XBAR_INPUT6, 18);
    GPIO_SetupPinOptions(18, GPIO_INPUT, GPIO_INVERT);

    EDIS;

        While the code below is not ok:

    EALLOW;

    XBAR_setInputPin(XBAR_INPUT5, 19);
    GPIO_SetupPinOptions(19, GPIO_INPUT, GPIO_PULLUP);
    InputXbarRegs.INPUT6SELECT = 18;
    GPIO_SetupPinOptions(18, GPIO_INPUT, GPIO_INVERT);

    EDIS;

        That is because the GPIO_SetupPinOptions(19, GPIO_INPUT, GPIO_PULLUP) has a EDIS in the end internally, so when it comes to InputXbarRegs.INPUT6SELECT = 18 there is no EALLOW, but XBAR_setInputPin(XBAR_INPUT6, 18) has EALLOW internally. So EALLOW problem...........

        Thanks for help