Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens with a premature 'return' in an ISR?

Tags:

People also ask

Can we use return in ISR?

So, at the end of ISR, 'IRET' is executed, the values of IP,CS, and flags are retrieved from stack to continue the execution of the main program. IRET or RETI is used to return from ISR.

What happens if the ISR is supposed to clear the interrupt flag and it didn t?

If an ISR doesn't clear the source of the interrupt when it exits, the kernel will immediately be re-interrupted by the Programmable Interrupt Controller (PIC — on the x86, this is the 8259 or equivalent) chip.

What happens when there is an interrupt within an interrupt?

Interrupts do not interrupt each other. The priority determines which interrupt handler get called first if more than one event happen at the same time or which event to service next if multiple interrupt events occur while in IRQ context.

What happens if the processor is in the middle of servicing ISR another interrupt comes?

The GIE bit is automatically cleared when your ISR starts running. The new interrupt will set its matching xxIF flag. If that flag is still set when the RETFIE instruction is executed at the end of the service (which sets GIE), another interrupt will be triggered immediately.


I'm using AVR-GCC 4.9.2, and I would like to know what happens if I do a premature return in an ISR on an AVR?

ISR(USART_RXC_vect)
{
    ...
    if(idx == BUFSIZE)
        return;
    ...
 }

Will the return be translated to a reti instruction? Or do I need to include a reti() myself?

I'm looking for a detailed explanation of what goes on behind the scenes.