CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC24EP - Disable interrupt inside interrupt or not?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
benoitstjean



Joined: 30 Oct 2007
Posts: 566
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PIC24EP - Disable interrupt inside interrupt or not?
PostPosted: Wed May 01, 2024 6:06 am     Reply with quote

Good day,

Just as a general question, I know it may have been already answered many times but I'm asking again.... I have a timer 1 interrupt. When the code jumps into the interrupt, should I disable it, do whatever has to be done then re-enable before the exit?

Or I just don't need to disable and re-enable an interrupt within that interrupt as this is all taken care of?

Thanks,

Ben
PrinceNai



Joined: 31 Oct 2016
Posts: 478
Location: Montenegro

View user's profile Send private message

PostPosted: Wed May 01, 2024 6:22 am     Reply with quote

Well, it depends on what you want to do inside that interrupt. Normally it should be something quick, done way before the next interrupt triggers. So I'd say no, no need to disable interrupt.
benoitstjean



Joined: 30 Oct 2007
Posts: 566
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Wed May 01, 2024 6:41 am     Reply with quote

But then let's say for argument's sake that the code inside the routine is "long", can the interrupt re-enter itself or it won't trigger until it has exit? I guess the other word is "nested" interrupt...?
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed May 01, 2024 6:43 am     Reply with quote

pretty sure, well mostly, that the compiler will disable it, do stuff..then reenable it on exit.

need to see the listing though.....
jeremiah



Joined: 20 Jul 2010
Posts: 1345

View user's profile Send private message

PostPosted: Wed May 01, 2024 7:54 am     Reply with quote

benoitstjean wrote:
But then let's say for argument's sake that the code inside the routine is "long", can the interrupt re-enter itself or it won't trigger until it has exit? I guess the other word is "nested" interrupt...?


An interrupt cannot re-enter itself. The PIC24s have various priority levels, but they tend to all default to the same priority level as each other, so they cannot interrupt each other. And a singular interrupt is by definition the same priority level as itself.

So you only need to worry about other interrupts and only if you manually change their priority level (and turn on the "nested interrupts" feature).

So the general rule is no you don't generally need to do any disabling of an interrupt inside itself. There are some niche cases like some PIC24s need to turn off the serial transmit ISR after you are finished sending data so it doesn't fire again with an empty queue, but those are pretty rare.

However, you should not be doing long interrupts, because they cannot interrupt each other usually. So having a long interrupt stops the other ISRs from firing on time. If you have a long interrupt it is usually not the design you want to use.
benoitstjean



Joined: 30 Oct 2007
Posts: 566
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Wed May 01, 2024 8:40 am     Reply with quote

Ok thanks.

It makes sense.

Cheers!

Ben
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group