Questions about SIGNAL vs. ISR

8 posts / 0 new
Last post
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

I was wondering about the difference between ISR and SIGNAL. I saw an earlier post, but it seemed as if the responses had been removed. Clawson had said something about using ISR and the xxx_vect defines.

Is it true that a SIGNAL( xxxx ) routine cannot be interrupted? Also, the xxx_vect and SIG_xxx are defined to be the same thing in the interrupt definition file. Why does it matter, is it a style thing?

One final question: I wanted to do a PIT (periodic interrupt timer.) The idea is to have a specific function be called every time a timer counter overflows. Should I call that function in the ISR, or should I have the ISR set a flag, and then have main() handle it? (I guessing the 2nd is the better one, but please let me know why it is better.)

DiodeDan

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

SIGNAL is the old way of doing it. ISR is the new way. The primary reason for the change is that there was a lot of confusion between SIGNAL, and INTERRUPT. SIGNAL executed the code with global interrupts disabled, like ISR does, so it could not be interrupted further by another interrupt source. INTERRUPT did not do this, and as such, caused problems for many users who didn't pay attention to the documentation.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

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

If your PIT function is very short, you can call it from within the ISR. If it takes a long time to execute (what "a long time" is depends on your application), just set a flag in the ISR. However, setting a flag introduces a longler latency.

If the function is not time critical, setting a flag is better, as this will improve the response times for other interrupts.

I tend to post off-topic replies when I've noticed some interesting detail.
Feel free to stop me.

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

I missed the part about the function call.. I don't suggest calling any functions from within an ISR. It is best to do the work in the isr directly, or for longer processing tasks, set a flag, and deal with it in the main loop.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

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

Also note that in recent avr-lib-c distributions with my patch, ISR() takes a second optional argument which can set the behaviour - ISR_NOBLOCK (equivelent to the old INTERRUPT), ISR_BLOCK (normal blocking behaviour) or a few other less commonly used attribute.

- Dean :twisted:

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

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

They might be less common, but they are cool: The ISR_NAKED attribute together with flags in GPIOR0 gives me a 2-cycle flag setting ISR.

I tend to post off-topic replies when I've noticed some interesting detail.
Feel free to stop me.

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

I'll move this to "GCC". DiodeDan, in future if making posts specifically about GCC, can you use that forum?

 

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

Ok, sorry.