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-TM4C129EXL: No GPIO Interrupt Occuring

Part Number: EK-TM4C129EXL

Hi I'm trying to get USR_SW1 to trigger an interrupt, but to no avail. My SysTick interrupt is working however.

I have my ISR set within the vector table in startup_ewarm.c

    GpioJIntHandler,                        // GPIO Port J

and believe I have configured it correctly, but I'm clearly missing something

//*****************************************************************************
//
// The interrupt handler for the SysTick interrupt.
//
//*****************************************************************************

void
SysTickIntHandler(void)
{
bSysTick = true;
}

void
GpioJIntHandler(void)
{
uint32_t status = GPIOIntStatus(GPIO_PORTJ_BASE, true);

GPIOIntClear(GPIO_PORTJ_BASE, GPIO_INT_PIN_0);

if (GPIO_INT_PIN_0 == (status & GPIO_INT_PIN_0))
{
bButton = true;
}
}

int
main(void)
{
MAP_SysCtlMOSCConfigSet(SYSCTL_MOSC_HIGHFREQ);

g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_240), 120000000);

//PinoutSet(false, false);

UARTStdioConfig(0, 115200, g_ui32SysClock);
UARTprintf("Ethernet lwIP TCP echo example.\n\n");

MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
while(!MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_GPION))
{
}

MAP_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);
MAP_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_1);

MAP_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, GPIO_PIN_0);
MAP_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, ~GPIO_PIN_1);

MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
while(!MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOJ))
{
}

MAP_GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_0);

MAP_GPIOIntRegister(GPIO_PORTJ_BASE, GpioJIntHandler);
MAP_GPIOIntTypeSet(GPIO_PORTJ_BASE, GPIO_PIN_0, GPIO_BOTH_EDGES);
MAP_GPIOIntEnable(GPIO_PORTJ_BASE, GPIO_INT_PIN_0);

MAP_IntMasterEnable();

MAP_IntEnable(INT_GPIOJ);


MAP_SysTickPeriodSet(g_ui32SysClock / SYSTICKHZ);
MAP_SysTickEnable();
MAP_SysTickIntEnable();

MAP_IntPrioritySet(FAULT_SYSTICK, SYSTICK_INT_PRIORITY);
MAP_IntPrioritySet(INT_GPIOJ_TM4C129, 0xE0);

while(1)
{
if (bSysTick)
{
bSysTick = false;

static uint32_t delay = 0;

if (50 == ++delay)
{
delay = 0;
MAP_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1,
(MAP_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_1) ^
GPIO_PIN_1));
MAP_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0,
(MAP_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_0) ^
GPIO_PIN_0));
}
}
}
}

>

  • Your code actually worked on my Launchpad, but I suspect that is just luck. You did not enable the internal pullup resistor for PJ0. Configured as an input, that pin was just floating. On my device it floated high enough to generate an edge when the button was pushed. On your device it probably did not float high.

    The solution is to add a call to GPIOPadConfigSet() to enable the internal pullup. I added the line immediately after the call to GPIOPinTypeGPIOInput()

    MAP_GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_0);
    MAP_GPIOPadConfigSet(GPIO_PORTJ_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

  • Thanks Bob, much appreciated as its now sprung into life. It's nonetheless fustrating as I'd looked in GPIOPinTypeGPIOInput() and seen there was already a call to GPIOPadConfigSet() so dismissed the notion of having to call it again.

    Cheers,

    HL

  • The problem with the call to GPIOPadConfigSet() in the function GPIOPinTypeGPIOInput() is that it did not enable the pullup. 

  • Indeed. Annoyingly I had previously been calling them seperately, but at that point I wasn't calling MAP_IntEnable(). The joys (and sorrows) that come with learning a new processor Slight smile