Tool/software: TI C/C++ Compiler
Hello,
I have been trying a solution in a thread to get GPIO interrupt working on EK-TM4C1294XL launchpad ( https://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/p/332605/1786938 )
The solution is given for TM4C123 so I have changed the port and pin to match with my board but it doesn't work. I already have a lot going on in my work-space (UARTs/ADC/Web server) so i am adding a few important things to verify:
Clock:
g_ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // // Configure the device pins. // // Configure SysTick for a 100Hz interrupt. SysTickPeriodSet(g_ui32SysClock / 100); SysTickEnable(); SysTickIntEnable();
Interrupt configuration:
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ); // Enable port J GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_0); // Init PJ1 as input GPIOPadConfigSet(GPIO_PORTJ_BASE, GPIO_PIN_0, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU); // Enable weak pullup resistor for PJ1 //---------------------------------------------- Interrupt setuü ----------------------------------------- GPIOIntDisable(GPIO_PORTJ_BASE, GPIO_PIN_0); // Disable interrupt for PJ1 (in case it was enabled) GPIOIntClear(GPIO_PORTJ_BASE, GPIO_PIN_0); // Clear pending interrupts for PJ1 GPIOIntRegister(GPIO_PORTJ_BASE, onButtonDown); // Register our handler function for port J GPIOIntTypeSet(GPIO_PORTJ_BASE, GPIO_PIN_0, GPIO_FALLING_EDGE); // Configure PF4 for falling edge trigger GPIOIntEnable(GPIO_PORTJ_BASE, GPIO_PIN_0); // Enable interrupt for PJ1
ISR:
void onButtonDown(void) { if (GPIOIntStatus(GPIO_PORTJ_BASE, false) & GPIO_PIN_0) { // PF4 was interrupt cause UARTprintf("Button Down\n"); // GPIOIntRegister(GPIO_PORTJ_BASE, onButtonUp); // Register our handler function for port F // GPIOIntTypeSet(GPIO_PORTJ_BASE, GPIO_PIN_0, // GPIO_RISING_EDGE); // Configure PF4 for rising edge trigger GPIOIntClear(GPIO_PORTJ_BASE, GPIO_PIN_0); // Clear interrupt flag } } void onButtonUp(void) { if (GPIOIntStatus(GPIO_PORTJ_BASE, false) & GPIO_PIN_0) { // PF4 was interrupt cause UARTprintf("Button Up\n"); GPIOIntRegister(GPIO_PORTJ_BASE, onButtonDown); // Register our handler function for port F GPIOIntTypeSet(GPIO_PORTJ_BASE, GPIO_PIN_0, GPIO_FALLING_EDGE); // Configure PF4 for falling edge trigger GPIOIntClear(GPIO_PORTJ_BASE, GPIO_PIN_0); // Clear interrupt flag } }
The Switch on launchpad SW1 and SW2 connected to J0 and J1, here i have tried to configure interrupt only of one button. Please let me know the valid method to initialize the GPIO interrupts and their priority.