Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 21st March 2005, 08:54 AM   (permalink)
Default HANDLING THE INTERRUPT.

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.
alamy is offline   Reply With Quote
Old 22nd March 2005, 06:39 AM   (permalink)
Default

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.
Pommie is online now   Reply With Quote
Old 23rd March 2005, 01:35 PM   (permalink)
Default

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
alamy is offline   Reply With Quote
Old 23rd March 2005, 01:55 PM   (permalink)
Default

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?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Old 23rd March 2005, 01:56 PM   (permalink)
Default

Quote:
Originally Posted by alamy
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...
__________________
"I share, thus I am"
Jay.slovak
Read this!
ICD2 Clone
Best PIC/DsPIC Bootloader

Read my Inchworm ICD2 review!
Jay.slovak is offline   Reply With Quote
Old 25th March 2005, 09:09 AM   (permalink)
Default

ok ..thanks...i get it..
alamy is offline   Reply With Quote
Old 26th March 2005, 03:37 PM   (permalink)
Default 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.
BF9000 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes




All times are GMT. The time now is 02:55 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.