Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Interrupt inside interrupt

Status
Not open for further replies.

d@nny

Full Member level 5
Joined
May 28, 2011
Messages
246
Helped
11
Reputation
22
Reaction score
11
Trophy points
1,298
Activity points
3,238
Is it possible for interrupt occures while other is in process
for example is this possible??????

the external interrupt occured and the mcu busy with it and not complete it but the port change interrupt occurs and while pic is in portchange interrupt the third interrupt pic timer0 interrupt occurs???????????? so there are three interrupts in process?

:evil:

---------- Post added at 21:52 ---------- Previous post was at 21:42 ----------

i mean i am using pic16f630 mcu
 

Once the pic receives an interrupt, it disables the interrupt service process, if another events occurs it will set the interrupt bit for the process. Then unless you clear all the interrupt flags before you exit the interrupt service routine (ISR), it will process these when you exit the ISR.
 

Yes recursive interrupts are possible in all mcu but usually disabled by default, in any case when this option is enabled then the first interrupt stops execution and executes the second interrupt which can be stopped and the third interrupt is executed etc until the last interrupt ends, then the execution of the previous interrupt continues until it ends and this goes all the way back until the first interrupt ends too and the execution returns to the main function.
I don't know if in your compiler for PIC is on by default but in the AVR compilers I have tried it is always off unless enabled.

Alex
 

I thought that with pic, another interrupt can not be serviced until the current is completed, at least on the 16f range.
 

yes, it would be possible for an interrupt to interrupt another one , For example 18f4550 has something called High and Low priority Interrupts , and you could determine which interrupt is high or low priority by IPR Registers .

a high priority interrupt can interrupt a low priority one .
regards
 

I thought that with pic, another interrupt can not be serviced until the current is completed, at least on the 16f range.

I have only worked with ARM and AVR which can execute recursive interrupts, unfortunately I haven't use PIC.

Alex
 

yes, it would be possible for an interrupt to interrupt another one , For example 18f4550 has something called High and Low priority Interrupts , and you could determine which interrupt is high or low priority by IPR Registers .
a high priority interrupt can interrupt a low priority one .
regards

The op stated he is using a 16f630 at the bottom of his post. that pic does not support interrupt priority.
 

yes, it would be possible for an interrupt to interrupt another one , For example 18f4550 has something called High and Low priority Interrupts , and you could determine which interrupt is high or low priority by IPR Registers .

a high priority interrupt can interrupt a low priority one .
regards

the high priority and low priority work only when two interrupts are triggered together at the same time, in this case the high priority interrupt will be serviced first followed by the lower priority one.

I think what the OP what to know is that if an interrupt can be generated while an interrupt is being serviced.

I think this is not possible on a PIC processor. It is for this reason an ISR must be kept as concise as possible.

More powerful processors would probably have separate interrupt handlers that would queue the interrupts as they come in according to priority levels assigned to them by the operating system or the BIOS.
 

HI, arbj

I have tried the following code in proton , to understand how priority interrupts are working , First I have two interrupt sources and they are int1 and int2 , I have declared that int1 is high priority interrupt and int2 is the low one.however, in Proteus if we triggered the two interrupts at the same time , a high priority interrupt would be serviced first , then the low interrupt as you mentioned before .
But it would be possible for a high priority interrupt to interrupt the low interrupt service routine (to do that I have made the ISR for the low one takes long time )

the code :
Code:
Device 18F4550 
Xtal = 20
'//////////////////////////////////////////////////////////
TXSTA.5=1 ' setting Transmit Enable Bit
RCSTA.7=1
RCSTA.4=1
Hserial_Baud 9600 ' Setting Baud rate
'/////////////////////////////////////////////////////////
Symbol IPEN          RCON.7      'enable disbale interrupts peiority
Symbol GIE_GIEH      INTCON.7   'GLOBAL Interrupts enable
Symbol PEIE_GIEL     INTCON.6   'SIDE DEVICES INTERRUPT ENABLE
Symbol INT0IF        INTCON.1   'INT0 FLAG
Symbol RBIE          INTCON.3   'Enable PORTB<7:4> Change status interrupt
Symbol RBIP          INTCON2.0   'PORTB<7:4> Priority flag
Symbol INTEDG1       INTCON2.5   'Rising/Falling edge Select
Symbol INTEDG2       INTCON2.4   'Rising/Falling edge Select
Symbol INT2IP        INTCON3.7   'INT2 PRIORITY
Symbol INT1IP        INTCON3.6   'INT1 PRIORITY
Symbol INT2IE        INTCON3.4   'INT2 interrupt enable
Symbol INT1IE        INTCON3.3   'INT1 interrupt enable
Symbol INT2IF        INTCON3.1   'INT2 FLAG
Symbol INT1IF        INTCON3.0   'INT1 FLAG
'/////////////////////////////////////////////////////////////
GIE_GIEH=1
PEIE_GIEL=1
IPEN=1
INT1IE=1
INT2IE=1
INTEDG1=1
INTEDG2=1
INT2IP=0
INT1IP=1
On_Interrupt GoTo ISRh:
On_Low_Interrupt GoTo ISRl:
main:
    HSerOut ["In MAIN       ","  INT1 = ",Bin1 INT1IF," INT2 = ",Bin1 INT2IF,13,13]
DelayMS 500
GoTo main

ISRl:
    Dim I As Byte
    HSerOut ["ENTER ISR LOW:","  INT1 = ",Bin1 INT1IF," INT2 = ",Bin1 INT2IF,13]
    If INT2IF =1 Then
        For I = 0 To 250
        HSerOut ["INT2 has occurred",13]
        
        Next I
        INT2IF=0
    End If
    HSerOut ["EXIT ISR LOW :","  INT1 = ",Bin1 INT1IF," INT2 = ",Bin1 INT2IF,13,13]
 Retfie  

ISRh:
    HSerOut ["ENTER ISR HIG:","  INT1 = ",Bin1 INT1IF," INT2 = ",Bin1 INT2IF,13]
    If INT1IF =1 Then
        HSerOut ["INT1 has occurred",13]
        INT1IF=0
    End If
    HSerOut ["EXIT ISR HIG :","  INT1 = ",Bin1 INT1IF," INT2 = ",Bin1 INT2IF,13,13]
 Retfie Fast
11


the results ( int1 is interrupted 1time per second and for int2 is (1hz) )
in normal situation wou would have :

In MAIN INT1 = 0 INT2 = 0

ENTER ISR HIG: INT1 = 1 INT2 = 1
INT1 has occurred
EXIT ISR HIG : INT1 = 0 INT2 = 1

ENTER ISR LOW: INT1 = 0 INT2 = 1
INT2 has occurred
EXIT ISR LOW : INT1 = 0 INT2 = 0

In MAIN INT1 = 0 INT2 = 0 .......


but if the high one occurred at high rate you will get :

ENTER ISR LOW: INT1 = 0 INT2 = 1ENTER ISR HIG: INT1 = 1 INT2 = 1
INT1 has occurred
EXIT ISR HIG : INT1 = 0 INT2 = 1


INT2 has occurred
EXIT ISR LOWE


I believe that the high priority interrupt has interrupted the low interrupt and then the low interrupt resume its routine .
regards
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top