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.
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.
Hello Alesh,
Do you have the following enable interrupt calls being used (they don't have to be ROM calls if you aren't using that):
ROM_IntMasterEnable(); ROM_IntEnable(INT_GPIOJ);
Also I would recommend starting a new project focused only on SW1/SW2 interrupts so you don't have anything else going on, and once you have the operation validated that way, you can then import it back into your main project and work on the priority aspect at that time.
Hello Ralph Jacobi,
Thank you for your valuable suggestion.
It lead me to to a relevant post which solved the problem.Ralph Jacobi said:IntEnable(INT_GPIOJ);
Although the week pull-up enabled by the line :
GPIOPadConfigSet(GPIO_PORTJ_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
didn't worked out for me(max voltage with week pull up at J0 was 180mV ). I had to add an external pull up to the J0 pin.