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.

Disable PWM output of PB6, PB7 from PD0 and PD1

Other Parts Discussed in Thread: TM4C123GH6PM

I would like to use the following ports for the specified function:

PWM: PB6, PB7

I2C: PD0, PD1

However, when I use PWM0 to generate PWM signals on PB6 and PB7 the same PWM is output on PD0 and PD1. I need to use PD0 and PD1 for I2C operation, so cannot have PWM being output on them.

How can I stop the PWM, from PB6 and PB7,  being output on PD0 and PD1, while still giving me the flexibility to use I2C on PD0 and PD1?

My code for PWM output and I2C work independently, but not when they are integrated. 

Thanks!

Kathleen

  • Hello Kathleen,

    You have not mentioned which TIVA part it is. For the TM4C123GH6PM the pads are not common between I2C and PWM based on the description. A code post would be useful along with information on the device

    Regards

    Amit

  • Once again - the superb launchpad's, "deliberate short-circuiting of those exact pins" plunges the user into darkness!

    We're told that the launchpad's designers made that, "(pin to pin * 2) MCU cross connection" to maintain compatibility w/the M0 killer (aka MPS family).

    If poster removes the 2, 0-ohm resistors marrying those MCU pins - proper (yet incompatible!) operation may ensue!

    Those 2 resistors are noted in board's schematic - splash of color/highlight would "save" the unwary...  Better still - have those (clearly minority few) wishing "compatibility" install those 0-ohms - do not force them "down the throats" of most new users - who seek ARM - not past, bit & processing reduced, technology...

    Amit - your green, "Verify stamp of approval" appears most appropriate, here...  (novice poster may be too new to issue such credit)

  • Oops! Major oversight on my part. The device is in fact a TM4C123G6PM. Do you want the full code? Below is just a snapshot. I have PA6, PA7, PB6, and PB7 as PWM outputs, however PD0 and PD1 output the same thing as PB6 and PB7, but I need PD0 and PD1 to be used for I2C. 

    Thanks for your help and quick response!

    /**** PWM Initializations ***/
    
        // Set the PWM clock to the system clock.
        SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
    
        // Enable GPIO peripherals A, B and PWM module 0 and 1
        // GPIO PWM: PA6, PA7, PB6, and PB7
        SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    
       // Configure the GPIO pin muxing to select PWM functions for pins PA6, PA7, PB6, PB7
        GPIOPinConfigure(GPIO_PA6_M1PWM2);
        GPIOPinConfigure(GPIO_PA7_M1PWM3);
        GPIOPinConfigure(GPIO_PB6_M0PWM0);
        GPIOPinConfigure(GPIO_PB7_M0PWM1);
    
        // Configure the GPIO pad for PWM function on pins PA6, PA7, PB6 and PB7.
        GPIOPinTypePWM(GPIO_PORTA_BASE, GPIO_PIN_6);
        GPIOPinTypePWM(GPIO_PORTA_BASE, GPIO_PIN_7);
    
        GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6);
        GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7);
    
        // Configure the PWM0 to count up/down without synchronization.
        PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
        PWMGenConfigure(PWM1_BASE, PWM_GEN_1, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC);
    
        // Set the PWM frequency period
        PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 100);
        PWMGenPeriodSet(PWM1_BASE, PWM_GEN_1, 100);
    
        //Enable PWM generators
        PWMGenEnable(PWM0_BASE, PWM_GEN_0);
        PWMGenEnable(PWM1_BASE, PWM_GEN_1);
    
    /**** I2C Initializations ***/
        // Enable I2C3 peripheral and GPIO D
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C3);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    
        // Configure the SCL and SDA for I2C3 functions on port D0 and D1
        ROM_GPIOPinConfigure(GPIO_PD0_I2C3SCL);
        ROM_GPIOPinConfigure(GPIO_PD1_I2C3SDA);
    
        // Select I2C function 
        GPIOPinTypeI2CSCL(GPIO_PORTD_BASE, GPIO_PIN_0);
        ROM_GPIOPinTypeI2C(GPIO_PORTD_BASE, GPIO_PIN_1);
    
        // Configure and Enable the GPIO interrupt. Used for INT signal from the
        // MPU9150
        ROM_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_2);
        GPIOIntEnable(GPIO_PORTB_BASE, GPIO_PIN_2);
        ROM_GPIOIntTypeSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_FALLING_EDGE);
        ROM_IntEnable(INT_GPIOB);

  • When you say "remove two 0 ohm resistors" are you talking software or hardware removal. Might seem like a dumb question but I just want to be sure.

    Thanks for your response!

  • As crack staff regularly comment - "Only cb1's questions are so classified."  Yours is fine.

    If you review the schematic you'll find that your subject pins are connected together. (extremely rare - damaging even - especially so if each are to be configured as outputs)  So - you simply remove or have someone remove both of those "0-ohm resistors" which "tie" your target pins together. 

    This has come up often - imho was always a questionable design decision - and vendor here appears tad unwilling to "change course" and perhaps better highlight (i.e. "some" highlight) this rather predictable pitfall...

    Removing those 2 0-ohm shunts will free the MCU's pin to pin connections - and restore the individuality  you (and 99% all others) expect & seek.

    It is customary that poster reward the responder (c'est moi) who correctly answers his/her issue...  Your particular MCU has little bearing here (as another suggested) - this is a board design decision gone wrong from its outset...

  • Any hint on where I may find the schematic? I didn't see one in their data sheet… 

    Thanks for the help and witty remarks!

  • Hi Kathleen,

         If you are using Tiva Launchpad, you can see its schematic at the Tiva Launchpad User's Guide.

    -kel

  • I had little faith that my question would be answered since it was my first time posting. I was definitely proved wrong. THANK YOU FOR YOUR HELP Amit, Kel, and cb!!

    One last question (maybe). If I were just to use the TM4C123GH6PM on my own PCB would I not need to worry about the 0-ohm resistor stuff (i.e. are PB6 and PD0, PB7 and PD1 only connected by 0 ohm resistors on the development board rather than the micro controller chip itself)?

  • Kathleen Gegner said:
    would I not need to worry about the 0-ohm resistor stuff

    Only if you engage the design team/individuals authoring that unfortunate - MCU pin to pin - forced connection.  Never should 2 MCU pins - potentially configured as push-pull (standard) outputs - be tied together.  Rather clearly - those 0-ohm shunts should be provided in a bag - to be installed only by (those few) who desire compatibility - w/bit & performance reduced, past MCU.  Compatibility should not trump usability - and when that (mistaken, I believe) path is taken - warning signposts should be well marked, highlighted and repeated.  Scant mention of this pin to pin "default" board condition (asterisk upon schematic, only) fails miserably as proved by the volume of such posts - landing here...

    Other than power pins - it is bit unusual (to be kind) to tie MCU pins together.  (although our group does just that in routing the MCU's analog comparator "output" to PWM Fault "input" - to enable a robust current-limiting - in our design scheme.  It may also serve to tie an external signal to two MCU analog input pins - enabling higher frequency analog conversions.

    KG: "One last question (maybe)."  Surely that deserves high note w/in, "Famous last Words."  So long as you reasonably study/prepare - avoid use of, "urgent or thinly disguised homework" - you should be well treated...

    This forum - by far - started as the best & has (imho) easily retained that title.  Many skilled, caring user participants & outstanding effort by vendor staff.  Welcome aboard!   (and that's a line, not a rope...)