Attaching pin to External Interrupt Control

Dear Sodaq forums,

I have been trying to use the external interrupt controller to generate an event for a counter, but so far the EIC does not appear to work as intended. In the code below, Pin A7, or PA07, is supposedly configured as a pulldown input, and MUXed to EXTINT7 in the PORT registers, which should allow the EIC to use it as an external interrupt source. When pulsing 3.3V on the pin with a button nothing happens though, and the handler does not light up the LED. Is someone able to help successfully trigger the event?
Code: Runs on Sodaq One V3
void EICSetup(void)
{
PM->APBAMASK.reg |= (PM_APBAMASK_EIC); //enable EIC in clock power manager

// 2. Configure Pin A7 and assign to EXTINT0
PORT->Group[0].DIRCLR.reg = (1 << 7);
PORT->Group[0].PINCFG[7].reg= (PORT_PINCFG_INEN | PORT_PINCFG_PMUXEN |PORT_PINCFG_PULLEN ); //Input Enable, MUX on, Pull Resistor
PORT->Group[0].DIR.reg = 0; //Configure as Input
PORT->Group[0].OUT.reg = 0; //Configure as Pull_down
//Pin MUX forwarding is asynchronous and has no delay
PORT->Group[0].PMUX[3].bit.PMUXO = 0; //PinMux to EXTINT7
// Configure External Interrupt Controller
EIC->INTENSET.reg |= EIC_INTENSET_EXTINT7; //Enable EXTINT0 Interrupt, see if not doing so still triggers Event
EIC->CONFIG[0].reg |= EIC_CONFIG_SENSE7_RISE ; //Detect rising edge
EIC->EVCTRL.reg |= EIC_EVCTRL_EXTINTEO7; //Enable Event trigger for every detection

//attach clock to EIC
SYSCTRL->OSC32K.bit.ONDEMAND = 0;
SYSCTRL->OSC32K.bit.RUNSTDBY = 1;
SYSCTRL->OSC32K.bit.EN32K = 1;
SYSCTRL->OSC32K.bit.ENABLE = 1;
while((SYSCTRL->PCLKSR.bit.OSC32KRDY) == 0);

GCLK->GENDIV.reg = ( GCLK_GENDIV_DIV(32) | GCLK_GENDIV_ID(RTC_GCLK_ID));
GCLK->GENCTRL.reg = (GCLK_GENCTRL_GENEN | GCLK_GENCTRL_SRC_OSC32K | GCLK_GENCTRL_ID(RTC_GCLK_ID));
while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY);

GCLK->CLKCTRL.reg = ( GCLK_CLKCTRL_ID_EIC | GCLK_CLKCTRL_GEN(RTC_GCLK_ID) | GCLK_CLKCTRL_CLKEN);
while ( GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY );

NVIC_EnableIRQ(EIC_IRQn);
}

void EIC_Handler(void)
{ EIC->INTFLAG.bit.EXTINT7 = 1; // if flag high and IRQ handler is called, write a 1 to remove flag setLedColor(WHITE); //indicate external interrupt has occurred }

Any tips would be greatly appreciated. The pin does not have to be A7, but any GPIO pin not used for I2C communication would be fine.
Sincerely
Daniel

Nevermind. After extensive digging in the manuals, not only does the event generator work but so does the counter which is supposed to keep track of the pulses. Problem solved

1 Like