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 support@ccsinfo.com

Interrupts Mix up question- Easy

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







Interrupts Mix up question- Easy
PostPosted: Tue Nov 09, 2004 10:13 pm     Reply with quote

Hi

I have another simple question: I have two types of interrupts, a RTCC interupt and a KeyBoardHit interrupt (I want to time the KBhits). What happens if while in the RTCC interrupt, the KB interrupt occurs?
Does the RTCC subroutine resume once the KB routine is finished?
Is there any way to get the RTCC routine to continue where it left off?

Thank you in advance for your help.
arrow
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Tue Nov 09, 2004 10:15 pm     Reply with quote

What PIC are you using? In PIC16s you can not have an interrupt inside another interrupt. In PIC18 a priority interrupt can occur in the middle of the ISR of a normal interrupt (which will resume once the priority ISR is over).
arrow
Guest







PostPosted: Tue Nov 09, 2004 10:18 pm     Reply with quote

Hi
I am using the PIC 16F84A, and am trying to time a pulse width.

arrow
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Tue Nov 09, 2004 11:33 pm     Reply with quote

From the datasheet:

Quote:
When an interrupt is serviced, the GIE bit is cleared to
disable any further interrupt, the return address is
pushed onto the stack, and the PC is loaded with
0004h. Once in the Interrupt Service Routine, the
source(s) of the interrupt can be determined by polling
the interrupt flag bits. The interrupt flag bit(s) must be
cleared in software before re-enabling interrupts to
avoid recursive interrupts.


So basically you can't have an interrupt inside another interrupt.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Nov 10, 2004 5:41 am     Reply with quote

Quote:
So basically you can't have an interrupt inside another interrupt.


Can't is such a strong negative. Laughing If you want to take a walk on the wild side, you can, and in some rare corner cases it may be desirable, to do so. To make this happen inside your interrupt handler you first have to disable the source of the current interrupt to avoid recursion and then enable global interrupts.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Nov 10, 2004 7:14 am     Reply with quote

Quote:
To make this happen inside your interrupt handler you first have to disable the source of the current interrupt to avoid recursion and then enable global interrupts.


Better have written your int handler. If you use the CCS's, the orginal working regs will get trashed. Posiible stack overflows. Bad idea to do this.

The other int still happens, it happens after the orginal int is finished. Now a trick that I used in the past was to insert a goto at the end of the int handler to goto the start of all the bit tests of CCS's int handler. This saves the time required to restore and then resave all the regs. You will have to make sure the int flags are cleared. Remember to keep those int handlers short!! This is a good reason why.
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