Electronic – AVR ATmega: can I trigger external interrupt by setting corresponding INTF flag bit

atmegaavrgpio-external-interruptinterruptsisr

I'm writing a C program for ATmega64A which has a INT0 ISR. This ISR should be executed in case of INT0 falling edge OR if the TIMER3 goes overflow.

To avoid doubling the code I'd like to trigger Int0 ISR in the Timer 3 overflow ISR.

Unfortunately there is no such information in the datasheet. At least in the INTF register description section:

enter image description here

Does anyone tries this? Or maybe someone knows this in theory?

Best Answer

Nope.

Writing a 1 to the flag will clear it. Writing a 0 will do nothing.


However, if you are using avr-libc and want to have two (or more) vectors having exactly the same code, this is possible. You use interrupt aliasing. An example (from here):

ISR(PCINT0_vect){  
    ...  
    // Code to handle the event.
}

ISR(PCINT1_vect, ISR_ALIASOF(PCINT0_vect));

In this example both PCINT0 and PCINT1 will share the same interrupt code - both entries in the vector table will point at the same function. This may be sufficient for your needs.