Continue to Site

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.

Interrupt on PIC

Status
Not open for further replies.

radialspel

New Member
Hello!

I'm going to start a new project with a pic16f84 and one of my quetions is how the interrupt on RA4 works. When does a interrupt happend?? is it only from low-to-high or/and reversed?? What happends in the MCU on a intterupt?? Does it just set a memmory or will it stop my program??

Thanks!
 
First of all, it's pin RB0 that has the interrupt feature, not RA4.

It can be set to respond to a high to low and to a low to high in software.
If an interrupt occurs then your pic will stop whatever it is doing and handle an interrupt routine immediately, when the interrupt routine is done it will continue were it left off...
 
interrupts

.. waht happends if to much interrupts occur??

and how can we calculate that ammout..??

TKS
 
Re: interrupts

TKS said:
.. waht happends if to much interrupts occur??

and how can we calculate that ammout..??

TKS

Too many shouldn't be able to occur, and you should design your code accordingly - when an interrupt is called the interrupt enable is turned off, you should reenable it when you exit your interrupt routine.

This applies to any system really, but it's particularly important on a PIC where you have a very small stack. If the stack overflows (on any system) it's likely to be a total disaster :lol:
 
There are no nested interrupts, except that a high priority interrupt can interrupt a low.

Repeated interrupts of the same type will only set the interrupt flag for that type. If the flag hasn't been cleared, it's lost.

Ex: You have the interrupt enabled on low-to-high transition of an RB0 pin. Button is pressed, RB0 interrupt flag is set, which causes the code to hault and enter the ISR. Your ISR checks all the flags and finds RB0 flag is set. This has taken a number of clock cycles, and the button has bounced which keeps causing the RB0 interrupt. Well, it's only reasserting the fact that the flag is 1. Your ISR code will eventually assign 0 to the flag and return to the main code.
 
Oznog said:
There are no nested interrupts, except that a high priority interrupt can interrupt a low.

Only on 18F pic's, 16F's don't have priority interrupts.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top