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.

tm4c123gh6pm : pins pb7 , pf0 are always high

Other Parts Discussed in Thread: EK-TM4C123GXL

i wos working on creating a spwm using pb6 and pb7 but suddenly now  whatever i do "even if i'm running an empty code or trying to set the to 0" the pins are always high even if i paused in the debugging mode 

i could't find any direct short between the 3.3v and the pins 

that's the code i used

#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/pin_map.h"
#include "driverlib/pwm.h"
#include "driverlib/sysctl.h"
uint16_t sinus[]={1,2,5,7,10,12,15,17,19,22,24,27,30,32,34,37,39,42,
                  44,47,49,52,54,57,59,61,64,66,69,71,73,76,78,80,83,85,88,90,92,94,97,99,
                  101,103,106,108,110,113,115,117,119,121,124,126,128,130,132,134,136,138,140,142,144,146,
                  148,150,152,154,156,158,160,162,164,166,168,169,171,173,175,177,178,180,182,184,185,187,188,190,192,193,
                  195,196,198,199,201,202,204,205,207,208,209,211,212,213,215,216,217,219,220,221,222,223,224,225,226,227,
                  228,229,230,231,232,233,234,235,236,237,237,238,239,240,240,241,242,242,243,243,244,244,245,245,246,246,
                  247,247,247,248,248,248,248,249,249,249,249,249,255,255,255,255,249,249,249,249,249,248,
                  248,248,248,247,247,247,246,246,245,245,244,244,243,243,242,242,241,240,240,239,238,237,237,236,235,234,
                  233,232,231,230,229,228,227,226,225,224,223,222,221,220,219,217,216,215,213,212,211,209,208,207,205,204,
                  202,201,199,198,196,195,193,192,190,188,187,185,184,182,180,178,177,175,173,171,169,168,166,164,162,160,
                  158,156,154,152,150,148,146,144,142,140,138,136,134,132,130,128,126,124,121,119,117,115,113,110,108,106,
                  103,101,99,97,94,92,90,88,85,83,80,78,76,73,71,69,66,64,61,59,57,54,52,49,47,44,42,39,37,34,32,30,
                  27,24,22,19,17,15,12,10,7,5,2,1};
int x=0,en=true;
long map(long , long , long , long , long );

void
PWM0IntHandler(void)
{

    PWMGenIntClear(PWM0_BASE, PWM_GEN_0, PWM_INT_CNT_LOAD);

    if(++x>311){x=0; en=!en;}
    if(en==true){
    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, 0);

    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, map(sinus[x],1,255,0,535));
    }
    else
    {
    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 0);

    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, map(sinus[x],1,255,0,535));
    }
}


int
main(void)
    {

    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_16MHZ);
    SysCtlPWMClockSet(SYSCTL_PWMDIV_1);


    SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    GPIOPinConfigure(GPIO_PB6_M0PWM0);
    GPIOPinConfigure(GPIO_PB7_M0PWM1);

    GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6);
    GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7);

    PWMGenConfigure(PWM0_BASE, PWM_GEN_0,
                    PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
    // equation: N = (1 / f) * SysClk.
    PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 535);

    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 64);
    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, 66);
    PWMOutputInvert(PWM0_BASE, PWM_OUT_0_BIT|PWM_OUT_1_BIT, true);

    IntMasterEnable();

    PWMIntEnable(PWM0_BASE, PWM_INT_GEN_0);

    PWMGenIntTrigEnable(PWM0_BASE, PWM_GEN_0, PWM_INT_CNT_LOAD);

    IntEnable(INT_PWM0_0);
    IntEnable(INT_PWM0_1);
    PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, true);
    PWMGenEnable(PWM0_BASE, PWM_GEN_0);
    while(1)
    {
    }


}
long map(long x, long in_min, long in_max, long out_min, long out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

thanks

  • Hello Samir,

    I believe your issue is because PD0 is tied with PB6 and PD1 is tied with PB7 pins via the R9 and R10 0 ohm resistors on the LaunchPad. If PD0 and PD1 are likely driving your pins high. Please remove R9 and R10, and try running your code again.

    By the way, you mentioned PF0 in the title but not in the post/code so I am assuming the issue is only for PB6/7.
  • my code dose't use pd0 and pd1 but pd1 is also high with pf0 and pb7 i uploaded and an empty code with main and nothing else and they are still high
  • Hello Samir,

    Have you removed the resistors from your board and confirmed PB6 and PB7 are still always high?

  • before removing the resistors

    pb7 - high

    pb6 - low

    pf0 - high

    pd0 - low

    pd1 - high

    after removing  the resistors

    pb7 - high

    pb6 - low

    pf0 - high

    pd0 - low

    pd1 - low

    i'm using this code for the test

    #include <stdbool.h>
    #include <stdint.h>
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/pwm.h"
    #include "driverlib/sysctl.h"
    
    
    
    int
    main(void)
        {
    
        SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_16MHZ);
    
        while(1)
        {
        }
    
    
    }
    
    

  • Hello Samir,

    I should have been specific and said, confirmed they are always high while running your PWM firmware.

    I reviewed the original firmware you posted and I didn't see anything that glared out to me as an issue yet. When you pause the debugger, does it land within a function as expected? (Want to make sure you aren't hitting an IntDefaultHandler or some other error/exception)

    If the issue is still occurring, I would suggest simplifying the code slightly and output from only one PWM to start, and then see if the waveform appears on your oscilloscope correctly. If so, then it could be an issue with the logic within the ISR statement.
  • the mentioned pins are always no matter what i do even with the empty code i posted that only have empty main function without any isr used still it's high
    when i pause the debugger the pins are still high and no it dose't hit indefaulthandler
  • Hello Samir,

    Hmm, I ran that same basic code on my own EK-TM4C123GXL LaunchPad and see that PF0 and PB7 stay low. I also ran your PWM code and it runs just fine.

    Is this a new LaunchPad? Do you think there is any chance it could have been subjected to an ESD event? Can you post a picture of the board so I can have a look at the pins/jumpers etc.?
  • Hey ralph

    It's not vary now just bought it month ago and l'm realy careful about ESD anyway these are the photos

  • Hello Samir,

    Regarding PF0, I think perhaps it may be the case that for your LaunchPad, the NMI default is still in place. Please see the first item of our post on common issues: https://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/374640

    That will explain the steps to unlock the Port, please try applying that to your LaunchPad and see if the PF0 pin returns to normal functionality.

    I haven't found any other reports of the issue with PB7 yet. All posts regarding that pin were due to the zero ohm resistor (which is why I was insistent about it's removal, we've seen it cause problems many times) Can you try running your code on the LaunchPad now that the zero ohm resistor that affects PB7 has been removed? When running the code with these changes applied, can you provide details on what behavior you observe between the pins? For example, is the PWM signal on PB6 correctly, but PB7 remains high throughout?

  • As always - in such circumstances - "KISS" very much, "Serves to RESCUE!"

    May I suggest that you, "Program both (suspect) pins to GPIO Outputs - and then toggle each."     Such most  "basic test"  should quickly/easily confirm,  "Pin's functionality."

    Indeed "PF0" is among the 2 (dreaded) NMI pins - and must be first unlocked -  prior to your forcing it into its (alternate) function.     (GPIO Output)

    Firm/I too - have little recollection of PB7's failure - except that,  "INVITED - by the unjustified continuance of those destructive "Plague-istors."     It may well be that the pin was damaged - due to that "Forced yet UNWANTED interconnect!"

    As an EASIER alternative - enabling your,  "Continuance w/your PWM-based project" - might you "Switch to another pair of PWM pins?"     (I believe that 3 separate PWM Generator pin-sets - all appear (thoughtfully) upon your LPad's headers.)      

    This method should  enable you to "Continue Progress" - even if - & especially if - your earlier noted pins were damaged!      Hopefully the "loss" of the earlier pin/pins will not prove eventful.   (one prays..)