Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

HANDLING THE INTERRUPT.

Status
Not open for further replies.

alamy

New Member
I have two interrupt, the first one is USART interrupt using hardware approach and another one is external interrupt at RBO interrupt, this one for USART software routine.

My software USART only receives the data while hardware USART do receive and transmit the data.

The case is, the interrupt occurred to my software USART (external interrupt, RBO) and than, it will process the data received, but before the task finish, the second interrupt which is hardware USART occurred, my question is, how PIC handle this thing?

I want my PIC finished the first task (software USART) and then process for the second one. So do if the interrupt hardware USART occurred first. The idea is …I want my PIC finish the task that come first and then continue for the second one…

Please advice…thanks in advance.
 

Pommie

Well-Known Member
Most Helpful Member
The interrupt will behave as you want it to. Interrupts are automatically disabled at the start of the interrupt and stay disabled until the retfie.

You can enable them while still in the interrupt by setting the Global enable bit, but re-entrant interrupts are not the easiest thing to get working.

I think that if I was doing this then I would only have the port b interupt and handle the hardware usart in the main loop.

HTH

Mike.
 

alamy

New Member
thanks ...but i still can't get the idea since i'll have two interrupt at the same time...

My confusion is on...when the first interrupt happen and suddenly the second interrupt coming...how the pic handle this interrupt...respond to the second one.?.

how should i do, if i want my PIC continue with first interrupt(completed the task) while at the same time respond to the second interrupt...

your comment are highly appreciated.

thganks
 

Nigel Goodwin

Super Moderator
Most Helpful Member
As Pommie already said, as soon as an interrupt is called any further interrupts are disabled. At the end of your interrupt service routine you should re-enable interrupts again - if there has been an interrupt whilst they were disabled, it will be triggered then.

But, like Pommie, I fail to see why you are wanting to try and use interrupts for both?.
 

Jay.slovak

Active Member
alamy said:
thanks ...but i still can't get the idea since i'll have two interrupt at the same time...

My confusion is on...when the first interrupt happen and suddenly the second interrupt coming...how the pic handle this interrupt...respond to the second one.?.

how should i do, if i want my PIC continue with first interrupt(completed the task) while at the same time respond to the second interrupt...

your comment are highly appreciated.

thganks
Ok, here's the point: If PIC is in ISR, and gets another interrupt request, the PIC keeps working on first interrupt. When it's done (RETFIE) it will re-enable interrupts and the second interrupt will take place. that's it...
 

BF9000

New Member
ISR

As soon as an interrupt occurs, the GIE (global interrupt enable) bit is cleared and the ISR is entered. This disables any further interrupts. However, interrupts flags may still be set during the ISR. As soon as the RETFIE instruction is executed, the GIE bit is automatically set. At this point, the ISR will be executed again if any unmasked interrupt flags were set. Remeber to clear the appropriate interrupt flag at the beginning of your ISR.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top