1
\$\begingroup\$

I have 3 buttons connected to PIN1, PIN3, PIN5 of PORTA of an XMEGA. If pushed they deliver a falling edge. I'm try to generate interrupt using those buttons, I started with one, here is what I have done:

void buttonINT(){
    // PORTA 
    PORTA.PIN1CTRL = PORT_OPC_PULLUP_gc | PORT_ISC_FALLING_gc;
    PORTA.INT0MASK = PIN1_bm;
    PORTA.INTCTRL = PORT_INT0LVL0_bm;
    PMIC.CTRL = PMIC_LOLVLEN_bm;
    sei();
    }
ISR(PORTA_INT0_vect){
    printf(" INTERRUPT \n");
}

in the main I call buttonINT() once , but I get the message all time printed?

Any idea what I'm doing wrong here?

\$\endgroup\$
1
\$\begingroup\$

You need to clear the interrupt flag in ISR(), something like:

PORTA.INT0FLAGS = PIN1_bm;

(I have not looked up the exact labels.)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.