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.

EK-TM4C1294XL: Non-discrete GPIO interrupt on Port P - Interrupt handler is never called

Part Number: EK-TM4C1294XL

Hi,

I am trying to set up PP0 and PP1 to have internal pull up resistors, then I have a switch tied to them and ground, when I hit the switch, I would like my interrupt to be called, recognize which pin was called and light up a corresponding LED., when the button is released, the switch is no long in position and the corresponding LED should be turned off.

I set breakpoints in the interrupt handler, but it seems that the interrupt handler is never called. Any help would be appreciated

void LegacyPulseMode (void)
{
    GPIOPinTypeGPIOInput(GPIO_PORTP_BASE, (GPIO_PIN_0 | GPIO_PIN_1));
    GPIOPadConfigSet(GPIO_PORTP_BASE, (GPIO_PIN_0 | GPIO_PIN_1), GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
    GPIOPinTypeGPIOOutput(GPIO_PORTP_BASE, GPIO_PIN_3 | GPIO_PIN_5); // PP3 = OUTPUT LED || PP5 = Enable LED
    GPIOIntTypeSet(GPIO_PORTP_BASE, (GPIO_PIN_0 | GPIO_PIN_1), GPIO_BOTH_EDGES); //Do not need discrete
    GPIOIntRegister(GPIO_PORTP_BASE, LegacyIntHandler);
    GPIOIntEnable(GPIO_PORTP_BASE, (GPIO_INT_PIN_0 | GPIO_INT_PIN_1 | GPIO_INT_PIN_2 | GPIO_INT_PIN_3 | GPIO_INT_PIN_4 | GPIO_INT_PIN_5  | GPIO_INT_PIN_6 | GPIO_INT_PIN_7));
    IntEnable(INT_GPIOP0);
    IntDisable((INT_GPIOP1 | INT_GPIOP2 | INT_GPIOP3 | INT_GPIOP4 | INT_GPIOP5 | INT_GPIOP6 | INT_GPIOP7));
}


// PP5 is tied to PP0
// PP3 is tied to PP1

void LegacyIntHandler (void)
{
    uint32_t status = 0;
    uint32_t read0 = 0, read1 = 0, read2=0;


    status = GPIOIntStatus(GPIO_PORTP_BASE, true);
    GPIOIntClear(GPIO_PORTP_BASE, status);

    read0 = GPIOPinRead(GPIO_PORTP_BASE, GPIO_PIN_0);
    read1 = GPIOPinRead(GPIO_PORTP_BASE, GPIO_PIN_1);
//    read2 = GPIOPinRead(GPIO_PORTP_BASE, GPIO_PIN_2);

    if(read0 == 0)
    {
        GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_5, GPIO_PIN_5);
    }
    else if(read0 == GPIO_PIN_0)
    {
        GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_5, 0x0);
    }

    if(read1 == 0)
    {
        GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_3, GPIO_PIN_3);
    }

    else if(read1 == GPIO_PIN_1)
    {
        GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_3, 0x0);
    }
}

  • Hey,
    Sorry, so the interrupt handler is actually being called only on PP0 but not on PP1, I am not sure why, I know I did :
    IntDisable((INT_GPIOP1 | INT_GPIOP2 | INT_GPIOP3 | INT_GPIOP4 | INT_GPIOP5 | INT_GPIOP6 | INT_GPIOP7));
    but the TivaWare Driver Lib says:

    "If this [GPIOIntEnable] call is being used to enable summary interrupts on GPIO port P or Q (GPIOIntTypeSet()
    with GPIO_DISCRETE_INT not enabled), then all individual interrupts for these ports must be
    enabled in the GPIO module using GPIOIntEnable() and all but the interrupt for pin 0 must be
    disabled in the NVIC using the IntDisable() function."
  • OK my bad, I fixed it, it was a hardware issue,

    I would delete the post, but I feel like maybe someone could benefit from it somehow.

    Sorry about the confusion.
  • Hi Hisham,

    No problem, no need to delete it, though if you want to elaborate on the hardware issue we can highlight that as the resolution in case anyone else runs into a similar hiccup?
  • It really has nothing to do with the MCU, one of the switches was using was faulty, so when it was being pressed, it was not pulling my pin down to GND, the pin would remain high so the edge would never change causing the interrupt never to be called.

    Now, the reason why I posted my original post was because I am new to this I assumed that I was doing something wrong in the code I had also double checked my circuit and everything was in place, I just assumed that I must have gotten the code wrong - much more likely than a faulty switch. However when I used a multimeter, I realized it was the switch.

    Sorry for the inconvenience and I hope the code can help somebody else.

    Thank you,

    Hisham Hafez