1
\$\begingroup\$

in my project it seems I must using internal interrupt instead of external interrupt because my MCU run out of external interrupt pin. Here is an internal interrupt example I've found here.

I am quite curios about what kind of side-effects will the internal interrupt will bring to the entire system, is there any advantage/disadvantage?

Kind regards.

\$\endgroup\$
  • 2
    \$\begingroup\$ It's like what is the advantage of using hands instead legs \$\endgroup\$ – Gregory Kornblum Jan 31 '17 at 6:04
  • \$\begingroup\$ "I must using internal interrupt " what exactly IS an internally interrupt? \$\endgroup\$ – dannyf Jan 31 '17 at 12:01
  • \$\begingroup\$ @dannyf the internal interrupt I mentioned here is a timer based listener \$\endgroup\$ – Yank Jan 31 '17 at 15:51
  • \$\begingroup\$ There isn't much comparability between an external interrupt and an "internal" interrupt, with the exception that a timer with a clock input can be configured as an external interrupt. \$\endgroup\$ – dannyf Jan 31 '17 at 16:40
1
\$\begingroup\$

That depends on a lot of factors.

Internal interruptions usually are timer interruptions, so, if you want to keep track of time, using internal interrupts are a good idea.

Just don't trust them too much, Keeping track of time for long periods (ie: more than a day) is usually done better by a RTC.

External interruptions are good for dealing quickly with external world events. Such as new data on serial port, a sensor being activated/deactivated, voltage change on your ADC, etc...

In matter of fact, if you have to respond to events (and you will), the question one must make is not if you should use internal or external interrupts, but if you must use an interrupt at all to deal with that event, or if just polling the port with your state machine (and you should be using one for dealing with simultaneous tasks in embedded environment) will do the trick.

There are situations, of course, when using external interruptions is the only choice. If you are in deep sleep mode, the microcontroller will shut down all timers, all "uncesssary" hardware, and even the RAM memory (all your data will be wiped out), and run the CPU on the slowest clock available. The only way to wake up the microcontroller in most models using external interruptions.

\$\endgroup\$
4
\$\begingroup\$

An external interrupt will use some external source (outside the microcontroller), such as a switch, motion sensor, or similar source, to trigger the interrupt.

An internal interrupt is triggered by some source inside the microcontroller, such as timer overflow, ADC data ready, UART data ready, etc.

Internal and External interrupts are not interchangeable - you have to use the one your interrupt source will trigger.

Edit:

I should have mentioned that what you do in the interrupt service routines will have much greater impact on the system performance than whether you use internal or external interrupts, as the main program will be paused while the interrupt service routine is running.

\$\endgroup\$
  • \$\begingroup\$ Thanks Peter, however I want to know what's the impact to the entire system such as speed , efficiency or energy cost by using these two different methods :) \$\endgroup\$ – Yank Jan 31 '17 at 6:29
  • 1
    \$\begingroup\$ I would expect the speed, efficiency, and energy cost of external and internal interrupts to be the same. You really have no choice in which type you use - if you want an external source to generate an interrupt, you must use an external interrupt. If you want an internal timer or ADC to produce an interrupt, you_must_ use an internal interrupt. \$\endgroup\$ – Peter Bennett Jan 31 '17 at 6:40
  • \$\begingroup\$ great!thanks Peter, additional question: what will you do if run out of external interrupt pins? - Kind regards \$\endgroup\$ – Yank Jan 31 '17 at 6:47
  • 2
    \$\begingroup\$ If you have more external interrupt sources than inputs, you would add some logic to combine a few sources into one interrupt pin, then have a way for the interrupt service routine for that input to determine the actual interrupt source, then perform the necessary function. \$\endgroup\$ – Peter Bennett Jan 31 '17 at 6:53
  • \$\begingroup\$ Also you can use more arduinos and make multiprocessor net, where each arduino manages some interrupts as much as possible and they coordinate just about what is necessary to share. My robot have one ardunio just for motor section and one just for sensors. thisrd is coordinating the two other on much higher management level (eg. when sensors say block eahed and on right and I am headindg North, then motors are commanded to retreat a itttle and then turn to right. If I am heading South the motors are commanded to move left ant continue straight) \$\endgroup\$ – gilhad Jan 31 '17 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.