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.

Configuring a non-defined port to pwm EK-TM1294XL

Other Parts Discussed in Thread: ENERGIA

Hello,

First of all thank you for any help.

I need to configure the pin PM0, or PM1, or PM2, or PM6 of my EK-TM1294XL as PWM.

But in the pinmap.h non of them have a #define to configure as PWM (GPIO_PM0_M0PWM0 doesnt exist), however in the datasheet those pins are shown as digitalwrite, so i think there has to be a way to configure them as PWM.

I know that there are many other pins that you can easily configure as PWM, indeed my code works perfectly with PF0 configured as PWM0, however i need one of those (PM0, PM1, PM2 or PM6). How can I configure them as pwm?

I am using the Tiva Lib and CCS,

Any help will by appreciated,

Carlos Salto

  • As you note - not ALL MCU GPIO may serve as (either) PWM or Timer capable. And - this limitation inflicts most all ARM MCUs - not just this vendor's.

    You may extend your choices by expanding your search to those MCU pins which (qualify) as Timers. You'll note that the Timers provide the means to produce a PWM Output at the MCU's select Timer pin(s).

    I believe that (only) those MCU pins listed as PWM or Timer will best serve your PWM desire. I suspect that your survey of both sets of MCU pins (PWM & Timer) will reveal at least one pin which may be "liberated" from more mundane, general GPIO duty.

    Should that not prove your case - while "nasty" and inefficient - you may "bit-bang" a GPIO into some form of "PWM-Lite" performance. (this much like voting - when both candidates are far from optimal...)
  • I agree, but i think these GPIOs serve as PWM as I have tried in energia the function analogueRead and it worked.

    What code should I use, in case its possible, to configure the pins (PM0, or PM1, or PM2, or PM6) as PWM configuration?. I would like to do something like this:

    SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
    GPIOPinConfigure(GPIO_PM0_M0PWM0);
    GPIOPinConfigure(GPIO_PM1_M0PWM1);
    GPIOPinTypePWM(GPIO_PORTM_BASE, GPIO_PIN_0);
    GPIOPinTypePWM(GPIO_PORTM_BASE, GPIO_PIN_1);
    PWMGenConfigure(PWM0_BASE, PWM_GEN_0,
    PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 1200); //Periodo de la PWM
    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 600); //Ciclo de trabajo inicial
    PWMDeadBandEnable(PWM0_BASE, PWM_GEN_0, 60, 60);
    PWMOutputState(PWM0_BASE, PWM_OUT_1_BIT | PWM_OUT_0_BIT, true);
    PWMGenEnable(PWM0_BASE, PWM_GEN_0);

    But this is not working as: #20: identifier "GPIO_PM0_M0PWM0" is undefined
    #20: identifier "GPIO_PM1_M0PWM0" is undefined

    I know it doesnt work because GPIO_PM0_M0PWM0 is not defined in the pinmap.h, however I need to use those pins.

    Thank you very much in advance,

    Carlos Salto
  • Carlos Salto said:
    I agree, but i think these GPIOs serve as PWM as I have tried in energia the function analogueRead and it worked.

    While you "agree" - your writing suggests otherwise - does it not?   It is doubtful that even the much heralded "e*" can turn a general GPIO (minus PWM or Timer capability) into a full-fledged PWM capable pin!   Of this - myself, my firm, others - have NO DOUBT!   (apologies to Ms. Stefani)

    I've advised that (both) PWM and Timer pins produce quality PWM Output in an efficient fashion.

    You state that you, "Need to use those pins."   And - it is likely that resulted from a, "too quick" read/review of the MCU manual and other MCU descriptive aids - is that not true?  

    If - as you suggest - that "ANY Pin" may be "teased into PWM compliance" - why would the vendor make such effort to LIST those pins deemed, "PWM Capable?"   Might your (backed now into a pin-usage corner) desire - "cloud" your thinking?

    In years past Alchemists sought to turn base metals into gold.   And today - (some) seek to turn "General GPIOs" into, "Fully PWM capable" pins.  

    Let the record show that, NEITHER WORK!   (despite "e*" and especially despite "e*"!)

  • Hello Carlos

    The PWM function on these pins are from Timer and not for the PWM module. So you should be using GPIO_PM0_T2CCP0 and not GPIO_PM0_M0PWM0. Also the configuration needs to be that for a timer in PWM mode and now PWM peripheral itself.