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-TM4C123GXL: Reading two interrupts from two different ports?

Part Number: EK-TM4C123GXL

Hello!

I'm trying to read two interrupts from two different ports, but it doesn't work. If I disable initialization of one port, the other will work fine. And vice versa. I'm using TivaWare, and I can't figure out what's wrong.

One interrupt is for reading remote controller values, and other for reading "data ready pin" of MPU6050.

I'll paste code for both interrupts below.

Thanks for your help!

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
SysCtlDelay(3);
GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_1);
GPIOIntDisable(GPIO_PORTD_BASE, GPIO_PIN_1);
GPIOIntClear(GPIO_PORTD_BASE, GPIO_PIN_1);
GPIOIntRegister(GPIO_PORTD_BASE, readMPU);
GPIOIntTypeSet(GPIO_PORTD_BASE, GPIO_PIN_1, GPIO_RISING_EDGE);
IntPrioritySet(INT_GPIOD, 0);
GPIOIntEnable(GPIO_PORTD_BASE, GPIO_INT_PIN_1);


SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlDelay(3); GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7); GPIOIntDisable(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7); GPIOIntClear(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7); GPIOIntRegister(GPIO_PORTA_BASE, RXChannel); GPIOIntTypeSet(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7, GPIO_BOTH_EDGES); IntPrioritySet(INT_GPIOA, 0); GPIOIntEnable(GPIO_PORTA_BASE, GPIO_INT_PIN_2 | GPIO_INT_PIN_3 | GPIO_INT_PIN_4 | GPIO_INT_PIN_5 | GPIO_INT_PIN_6 | GPIO_INT_PIN_7);

 

  • Hi,
    When both are activated which interrupt never happened? Is it the PORTD interrupt never happened? You have set both PORTA and PORTD to the same interrupt priority. However, since PORTA is lower indexed than PORTD, the PORTA will be serviced first. If PORTA interrupt comes frequently compared to PORTD then it is possible that PORTA is not serviced. Another thing to check is if you have cleared the interrupt flag in PORTA ISR. If the highest priority pending flag is not cleared then it will re-enter PORTA ISR as soon as it exits the ISR.
  • I don't understant the first sentence. What would be then optimal solution? I'm clearing interrupt flags in both interrupts.
    Thanks!
  • Hi,

    I'm asking if you are always getting interrupt on the PORTA only? Can you put a breakpoint in the PORTA ISR and check if the PORTD interrupt flag is set. If PORTD interrupt flag is set when you are in PORTA ISR then this means the PORTA interrupts come very frequent. Since PORTA has higher hardware priority than PORTD given the same software priority level as you use IntPrioritySet() to set the same software priority for both interrupts, the PORTA ISR will always get serviced first. Also note that in your PORTA interrupt configuration you have so many pins (pin 2,3,4,5,6,7) that can generate interrupts onto PORTA ISR this will certainly come more frequently than PORTD. Try to make PORTA lower priority than PORTD and try again.