Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
DiodeDan
PostPosted: Aug 10, 2008 - 11:02 PM
Rookie


Joined: Aug 01, 2008
Posts: 49


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
 
 View user's profile Send private message  
Reply with quote Back to top
glitch
PostPosted: Aug 10, 2008 - 11:49 PM
Raving lunatic


Joined: Jan 12, 2002
Posts: 7835
Location: Canada

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.
 
 View user's profile Send private message  
Reply with quote Back to top
buffi
PostPosted: Aug 11, 2008 - 12:24 AM
Resident


Joined: Aug 24, 2001
Posts: 513
Location: Hamburg, Germany

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.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
glitch
PostPosted: Aug 11, 2008 - 12:54 AM
Raving lunatic


Joined: Jan 12, 2002
Posts: 7835
Location: Canada

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.
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Aug 11, 2008 - 03:52 AM
Moderator


Joined: Jan 23, 2004
Posts: 10215
Location: Melbourne, Australia

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 Evil

_________________
Make Atmel Studio better with my free extensions. Open source and feedback welcome!
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
buffi
PostPosted: Aug 11, 2008 - 07:47 AM
Resident


Joined: Aug 24, 2001
Posts: 513
Location: Hamburg, Germany

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.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
clawson
PostPosted: Aug 11, 2008 - 11:42 AM
10k+ Postman


Joined: Jul 18, 2005
Posts: 71149
Location: (using avr-gcc in) Finchingfield, Essex, England

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

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
DiodeDan
PostPosted: Aug 18, 2008 - 01:16 AM
Rookie


Joined: Aug 01, 2008
Posts: 49


Ok, sorry.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits