muliple return points from int routine?

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi :)

I have a timer1 function that I need to exit from several
points depending on the value of some variables.

Is it ok to exit a timer interrupt from several points using
return; ?? I know it is ok from a regular function.

SIGNAL(SIG_OUTPUT_COMPARE1A) //this code runs 10,000/sec
{

.........
return;

........
return;

........
return;

}
 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Far as I know should work dandily (perfectly). The compiler would, I assume, make each return jump to the appropriate ISR epilogue code.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Gwen,

Yup there's no problem with that - the compiler is sensible enough to use pops/RETI for each "return;" (in fact possibly the same pops/RETI with jumps to it)

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks guys :)

I was worried that all the stuff that needed to be done when
exiting a timer interrupt function might be missed if I just
jumped out via a return;

On looking at the asm code generated by a return; I see that
it simply creates a goto that points at the end of the function
code (where the exit code is always placed)

+000000D2:   C006        RJMP    PC+0x0007        Relative jump