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.

dead-band PWM from pins PK4 PK5 does not work - muxing problem?

Hello,

I use the TM4C129EXL evaluation kit.

I want to use 4 PWM, 2 couples of PWM with dead band mode. To do so, I use the following code wich configure the pins PF2 and PF3 (module 0 generator 1), and PK4 and PK5 (module 0 generator 3).

I use the code given in the exemple "dead_band.c". I adapted it and it works fine for the couple PF2 and PF3. But with PK4 and PK5, nothing happen. I thought it was a muxing problem sinc PK4 and PK5 are used for the ethernet LED.

Thank you for your help.

Here is the code:

int
main(void)
{
        PinoutSet(false,false);
SysCtlPWMClockSet(SYSCTL_PWMDIV_1); SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK); HWREG(GPIO_PORTK_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; HWREG(GPIO_PORTK_BASE + GPIO_O_CR) = 0x01; HWREG(GPIO_PORTK_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; HWREG(GPIO_PORTK_BASE + GPIO_O_CR) = 0x02; HWREG(GPIO_PORTK_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; HWREG(GPIO_PORTK_BASE + GPIO_O_CR) = 0x04; HWREG(GPIO_PORTK_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; HWREG(GPIO_PORTK_BASE + GPIO_O_CR) = 0x08; HWREG(GPIO_PORTK_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; GPIOPinConfigure(GPIO_PK4_M0PWM6); GPIOPinConfigure(GPIO_PK5_M0PWM7); GPIOPinTypePWM(GPIO_PORTK_BASE, GPIO_PIN_4); GPIOPinTypePWM(GPIO_PORTK_BASE, GPIO_PIN_5); PWMGenConfigure(PWM0_BASE, PWM_GEN_3, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_3, 64000); PWMPulseWidthSet(PWM0_BASE, PWM_OUT_4, PWMGenPeriodGet(PWM0_BASE, PWM_GEN_3) / 4); PWMDeadBandEnable(PWM0_BASE, PWM_GEN_3, 160, 160); PWMOutputState(PWM0_BASE, PWM_OUT_5_BIT | PWM_OUT_4_BIT, true); HWREG(GPIO_PORTK_BASE + GPIO_O_CR) = 0x00; HWREG(GPIO_PORTK_BASE + GPIO_O_LOCK) = 0; ////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinConfigure(GPIO_PF2_M0PWM2); GPIOPinConfigure(GPIO_PF3_M0PWM3); GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_2); GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_3); PWMGenConfigure(PWM0_BASE, PWM_GEN_1, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, 1200); PWMPulseWidthSet(PWM0_BASE, PWM_OUT_2, PWMGenPeriodGet(PWM0_BASE, PWM_GEN_1) / 4); PWMDeadBandEnable(PWM0_BASE, PWM_GEN_1, 160, 160); PWMOutputState(PWM0_BASE, PWM_OUT_3_BIT | PWM_OUT_2_BIT, true); PWMGenEnable(PWM0_BASE, PWM_GEN_1); PWMGenEnable(PWM0_BASE, PWM_GEN_3); while(1) { } }

  • Find out myself.

    First of all I removed all the HWREG(...) because their purpose here is done by GPIOPinConfigure(...).
    I added a "SysCtlClockFreqSet()" line that was in a comment part.

    The real problem was the "PWM_OUT_XXX" arguments. Instead of using the number of the PWM, I used the number of the pin in the port K.

    So I replaced PWM_OUT_4 by PWM_OUT_6 and PWM_OUT_5 by PWM_OUT_7.

    Everithing is fine now
  • Hi Fabien,

    I am glad you were able to debug and resolve the issue on your own. Let us know if any additional problems arise that you can't resolve on your own and we will be glad to help you work through them.