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: interrupt-ability of pins, and multi pin interrupts

Part Number: TM4C123GH6PM

Hello,

Is there any limitation on the pins where we can attach an interrupt on the tm4c123gh6pm?

And also, when we have 2 pins on the same port that are interrupt pins, do we attach multiple isr's per pin or just one isp per port:

Looking from examples, I have done something like:

void isr(void) {
    if(GPIOIntStatus(GPIO_PORTC_BASE, true) & GPIO_PIN_6) {
        GPIOIntClear(GPIO_PORTC_BASE, GPIO_PIN_6);
    } else if(GPIOIntStatus(GPIO_PORTC_BASE, true) & GPIO_PIN_5) {
        GPIOIntClear(GPIO_PORTC_BASE, GPIO_PIN_5);
    }
}

And I initialize both pins with:

    GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6);
    GPIOPadConfigSet(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
    GPIOIntDisable(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6);
    GPIOIntClear(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6);
    GPIOIntRegister(GPIO_PORTC_BASE, isr);
    GPIOIntTypeSet(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6, GPIO_RISING_EDGE);
    GPIOIntEnable(GPIO_PORTC_BASE, GPIO_PIN_5 | GPIO_PIN_6);

And in my ISR's I usually set a volatile boolean to true, then process this in my main loop.

Is there a better way of doing this? For example instead of clearing the interrupt inside the isr, could i check in my main loop GPIOIntStatus(GPIO_PORTC_BASE, true) and then clear the interrupt. (provided that another interrupt will not come before the loop processes it.

Best Regards,

C.A.

  • Hello C.A.

    You have the right methodology here.

    There aren't individual per pin ISRs, so you need to use a single ISR for the whole port and parse through which pin has the interrupt to take an action.

    Using the global flags (with them set to volatile) as you are currently is a very common approach, but you could just poll in your loop if you prefer for your use case. That's an end user decision. The global flag approach allows for quickest processing.

    Best Regards,

    Ralph Jacobi