Other Parts Discussed in Thread: EK-TM4C123GXL
Tool/software: Code Composer Studio
Hello,
I'm trying to generate an interrupt on pressing the SW1 (PF4), but it doesn't seem to work and I don't know what I'm doing wrong... Here is the code in main.c:
int main() { SYSCTL->RCGCGPIO |= (1U << 5); /* enable Run mode for GPIOF */ SYSCTL->GPIOHBCTL |= (1U << 5); /* enable AHB for GPIOF */ GPIOF_AHB->DIR |= (LED_RED | LED_BLUE | LED_GREEN); GPIOF_AHB->LOCK = 0x4C4F434B; GPIOF_AHB->CR = 0xFF; GPIOF_AHB->DEN |= (SW2 | LED_RED | LED_BLUE | LED_GREEN | SW1); GPIOF_AHB->PUR |= (SW2 | SW1); GPIOF_AHB->IS &= ~(SW1); // edge detect for SW1 GPIOF_AHB->IBE &= ~(SW1); // only one edge generate the interrupt (set into IEV) GPIOF_AHB->IEV |= SW1; // a rising edge triggers the interrupt __enable_irq(); while (1) ; }
In another file bsp.c I defined the function GPIOPortF_IRQHandler, which is also in the vector table:
void GPIOPortF_IRQHandler(void) { GPIOF_AHB->DATA_Bits[LED_RED] = LED_RED; GPIOF_AHB->DATA_Bits[LED_GREEN] = LED_GREEN; GPIOF_AHB->DATA_Bits[LED_BLUE] = LED_BLUE; }
The GPIORIS register is changing when I push the button, but the GPIOPortF_IRQHandler function is not called... Can you please tell me what am I doing wrong here?