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: Port J pins PJ-0 and PJ-1 with separate ISRs

Part Number: EK-TM4C1294XL

Dear Sirs

I'm using the user buttons, USR_SW1 and USR_SW2, on the EK-TM4C1294XL Launch Pad to trigger their separate ISRs.  Please see initialization code below.

//*************************************************************************
// Enable and configure port J for use with user buttons on TIVA Launchpad.
//*************************************************************************
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_0 | GPIO_PIN_1);
GPIOPadConfigSet(GPIO_PORTJ_BASE, GPIO_PIN_0 | GPIO_PIN_1, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);
GPIOIntTypeSet(GPIO_PORTJ_BASE, GPIO_PIN_0 | GPIO_PIN_1, GPIO_FALLING_EDGE);
//
// These interrupts are re-mapped to ISR functions
// found within this file.
//
GPIOIntRegister(GPIO_PORTJ_BASE, &UserButton1ISR);
GPIOIntRegisterPin(GPIO_PORTJ_BASE, GPIO_PIN_0, &UserButton1ISR);
GPIOIntRegister(GPIO_PORTJ_BASE, &UserButton2ISR);
GPIOIntRegisterPin(GPIO_PORTJ_BASE, GPIO_PIN_1, &UserButton2ISR);

When I push the USR_SW1 button, which should trigger UserButton1ISR, UserButton2ISR is triggered.  USR_SW2 triggers UserButton2ISR as it should.  Is my initialization code wrong?  Below is my interrupt enable code.

IntMasterEnable();
IntEnable(INT_GPIOJ);
GPIOIntEnable(GPIO_PORTJ_BASE, GPIO_INT_PIN_0 | GPIO_INT_PIN_1);

Thank you for your time.

  • Hi,

      If you are going to register the interrupt vector individually for each pin (e.g. PJ0 and PJ1) then you don't want to call GPIOIntRegister(GPIO_PORTJ_BASE, &UserButton2ISR) in your code. With this call, it means any pins in port J is mapped to &UserButton2ISR. I think this is why when you press USR_SW1, it goes to UserButton2ISR vector. You should change:

    from:

    GPIOIntRegister(GPIO_PORTJ_BASE, &UserButton1ISR);
    GPIOIntRegisterPin(GPIO_PORTJ_BASE, GPIO_PIN_0, &UserButton1ISR);
    GPIOIntRegister(GPIO_PORTJ_BASE, &UserButton2ISR);
    GPIOIntRegisterPin(GPIO_PORTJ_BASE, GPIO_PIN_1, &UserButton2ISR);

    to:

    GPIOIntRegisterPin(GPIO_PORTJ_BASE, GPIO_PIN_0, &UserButton1ISR);
    GPIOIntRegisterPin(GPIO_PORTJ_BASE, GPIO_PIN_1, &UserButton2ISR);

  • Dear Charles

    Thank you for your quick response.  Unfortunately, your suggestion didn't work as expected.  It seemed reasonable.  When I removed the port-J registration only as you suggested, I had no interrupts at all.  I swapped the order of the registrations, and as I would have suspected. only the button 1 interrupt works for both buttons.  It seems the last interrupt to get registered is active.  

  • Hi Dennis,

      I think I know the reason. After reading the interrupt vector table mapping in the datasheet again, I realize that Port J only has one common interrupt vector that is for all 8 pins within the port. You can not have individual interrupt vector for each port J pin. The per-pin interrupt vector is only available for port P and port Q but not port J. Please refer to Interrupts table in the datasheet. 

  • Dear Charles

    Thank you for the explanation.  This resolves my issue.