Can anyone help me understand the difference between the Pin change interrupt and Exernal Interrupt on Atmega 328?
External interrupts have their own interrupt vector.
Pin change interrupts share an interrupt vector. The code in your interrupt handler has to decide which pin caused the interrupt.
External interrupts were first. They are supported by the Arduino library.
With the introduction of the newer chips like the ATmega328p, almost every pin got its own interrupt (pin change interrupt). But some other microcontrollers, like the ATmega2560 and the ATmega32u4 don't have that on every pin.
There is also a library for the pin change interrupt.
So by configuring the pins properly can we use any pin of the Atmega 328 as an interrupt pin? and with interrupts on change,rise,fall,low etc..?
just think it like placing order in a resterant.
External Interrupt works like processing orders per individual person, so when a waiter serves you the meal, he/she knows exactly which customer place the order. Pin Change Interrupts works like going to restaurant with your family, the waiter serves you tomato soup, you and your family have to determine which one of you ordered it, else you're might be eating your mom's soup, or your sister's pudding.
The main difference is that with external interrupts the ISR ‘knows’ explicitly what pin number generated the interrupt, The ISR function does not need to read the input pin at all, but with pin change interrupts the ISR must perform more software logic steps to determine which explicit pin in the port caused the interrupt.
saravananm92: So by configuring the pins properly can we use any pin of the Atmega 328 as an interrupt pin?