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.

TM4C1231H6PM: Timer based PWM control and open drain

Part Number: TM4C1231H6PM

Hello,

I am hoping to get some clarification on using a Timer based PWM output to control a couple cathodes of a tri-color common anode LED. I setup the pins to be gpio outputs od (open drain) with GPIOPinTypeGPIOOutputOD followed by a pad config to set the pin strength to 12ma and open drain with a GPIOPadConfigSet. 

My question is,  when I configure those pins later with a GPIOPinConfigure(GPIO_PD6_WT5CCP0) and a GPIOPinTypeTimer(GPIO_PORTD_BASE, GPIO_PIN_6) for example, is that just blowing away my previous open drain settings? I don't quite understand where the cut off is from a pin being a standard gpio to a timer pwm gpio. 

Is it possible to set a gpio timer pwm pin to be open drain?

Any insight would be greatly appreciated!

  • Greetings,

    Jeff_e2e said:
    ... using a Timer based PWM output to control a couple anodes of a tri-color common cathode LED.

    Unless I've not sufficiently recovered from holiday celebrations - it appears that 'Open Drain' makes (pardon) little sense for your Anode Control application.    Does not Open Drain enable multiple devices to 'Tie together & selectively 'pull-down?'    That OD thus seems a poor match to the anode of any led - as a pull-up resistor or (some other) form of anode control - must be employed.    (Note: in the case of certain high-current Leds (unfortunately not yours) (12mA) an OD output may drive (enable) a small power stage - which in turn provides current drive to the Leds' Anode.)

    Your solution may lie in placing your timer outputs into 'Push-Pull' mode - in which (both) current may be 'sourced' or 'sunk' - with 'sourcing' being appropriate in your (drive the Leds' Anode) case.

    Again - your desire for open drain appears, 'Not proper for your Anode Drive, Common Cathode' Led application...

  • My apologies. I must be the one recovering from the holidays. I swapped my LEDs around. Common anode (+) multiple cathodes (-). I fixed my description in the original post. 

  • Jeff_e2e said:
    I swapped my LEDs around.

    Good that - at least that you've deployed the 'easier to drive' common anode Leds.

    Now it may well be that when in Timer Mode - OD output is not enabled.   (so that the timer can more notably drive other devices - I suspect that the addition of an OD's pull-up R would slow & round) the Timer Output - thus explaining the enforced disabling of OD - while the pin is w/in Timer Mode!)   I've not easy access to the MCU manual at the moment - yet it should reveal if your OD selection is indeed - being, 'over-ridden.'   In addition - you may review the source code for both functions (below) & see if there is a hint of pin restriction.

    Also - perhaps the 'order' in which you configure:

    •  GPIOPinConfigure()

    and

    • GPIOPinTypeTimer()

    (may) be 'order' sensitive.    (thus - try both ways!)

    Should the timer outputs not be able to be so commanded (as OD) - you may write code so that, Non-Timer, GPIO pins are toggled based upon the Timer's logic level.   As you know - normal GPIO have no such OD restrictions!

  • Hello Jeff,

    I too am recovering from the holidays as I misinterpreted 'fixed description' as 'fixed problem'. Sorry for that.

    cb1 is on the right track here with the order of commands mattering, specifically using the GPIOPinTypeTimer API.

    The GPIOPinTypeTimer will call a TivaWare defined GPIOPadConfigSet which would override your own GPIOPadConfigSet settings if you want to use differing settings from what is provided in TivaWare which are:

        //
        // Set the pad(s) for standard push-pull operation.
        //
        GPIOPadConfigSet(ui32Port, ui8Pins, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);

    So you would need to shift your GPIOPadConfigSet to be after the GPIOPinTypeTimer API is called.

  • Per the usual, cb1 nailed it. Reordering the function calls has me up and running timer based pwm gpio pin with an open drain. Apologies for the early naming confusion.  

    Thank you Ralph and cb1

  • Jeff_e2e said:
    Per the usual, cb1 nailed it.

    Thank you my friend.    Crack staff of course, 'Rolled their pretty eyes' at your kind comment - noting, "Why don't you ever guide us properly?"

    Should several young (mostly gurl) staffers 'Go Missing' ... its doubtful that any Jury would convict...    Glad that you're, 'On the Air!'