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.

pic16f628a interrupt help?

Status
Not open for further replies.

5282

Junior Member level 2
Joined
Dec 5, 2015
Messages
21
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
160
hiiiiiii,
i want to active two interrupt at same time
timer1 and portB0 interrupt

:thinker:
 

This is impossible, sorry.
images
 

thank you Easyrider83
but i will make 220v dimmer and i want portB0 interrupt for zero crossing and timer1 interrupt for 7segment and timing delay ??
 

I think the issue here are the words "at the same time".
That MCU has a single interrupt vector and while it is servicing an interrupt the MCU will not interrupt that to service another one.
However that does not stop 2 interrupt sources being active at the same time.
One way you might be able to do this is to use the fact that you need to detect the actual interrupt source yourself within the ISR. You typically do this with code such as:
Code:
if(INTCONbits.INTE && INTCONbits.INTF)
{
    // service the external interrupt
    INTCONbits.INTF = 0
}
if(INTCONbits.T0IE && INTCONbits.T0IF)
{
    // service the timer interrupt
    INTCONbits.T0IF = 0
}
(the idea is correct - you may need to change the code for whatever compiler you are using)
What will happen then is that either (or both) sources will trigger the ISR. The first thing it will check is to see if that was the external interrupt and do whatever is required if it was. Regardless of that, it will then check to see if the timer interrupt has triggered and service that if it has.
It may happen that the external interrupt will trigger while the ISR is processing the timer interrupt (in other words the external interrupt was not triggered at the time the ISR started but while it was running). In that case the ISR will finish and then be called again but the hardware as the INTF (and INTE) bit(s) will still be set.
Susan
 
  • Like
Reactions: 5282

    5282

    Points: 2
    Helpful Answer Positive Rating
Basicaly, all pic microcontrollers have only one interrup vector. So, all interrupts will be executed the same time. It is just a question which flag will be hanlded first.
 
  • Like
Reactions: 5282

    5282

    Points: 2
    Helpful Answer Positive Rating
@Easyrider83: Not really relevant to this question but the PIC18 and smaller families have one or two interrupts and, where there are two, they are 'high' and 'low' priority where the high priority ISR casn interrupt the low priority on e if it is running.
The PIC24/dsPIC33 and PIC32 families have multiple interrupt vectors (typically one for each peripheral) that have multiple priority levels where a higher priority ISR can interrupt a lower priority one.
However this is a level of complexity that the OP need not worry about with this MCU.
Susan
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top