External Interrupt vs PinChangeInterrupt

Hi

I'm studying the AVR and I can't understand what is the difference between External Interrupt and PinChangeInterrupt

I can understand what is a PinChangeInterrupt.

But, so, what is an External Interrupt if not a PinChangeInterrupt ?

Similar things but external interrupt belongs o exact pin and pin change int. usually is for group of pins (on same port) thus you have to test which pin exactly has been changed.

What difference between INT0/INT1 and PCINT [23:0] when

INT0 is PCINT 18
and
INT1 is PCINT 19

PCINT 18 and PCINT 19 are included in PCINT [23:0] !

PCINT 19 and PCINT 18 are configured with the same register as all others PCINT [23:0] pin !

But they are also configured with EICRA and EIMSK register ! wich is very strange and confusing!

If an interrupt occurs on pin PB7 wich is also PCINT 7 , PCIF0 in PCIFR register is set to 1.
So I know an interrupt has occurred on one of the goup PB7:PB0 pin. But How do I know exactly on what pin it has occured ?

Any explanation ? These interrupt with all these register are very confusing to me

So I know an interrupt has occurred on one of the goup PB7:PB0 pin. But How do I know exactly on what pin it has occured ?

In the ISR function your create that services the pin change interrupt you have to read the port value and compare it with a prior saved value the port held prior to the interrupt and at the end of the ISR save this 'new' port value as the 'prior port' value, With this information you can determine which pin in the port caused the interrupt.

hary:
But, so, what is an External Interrupt if not a PinChangeInterrupt ?

They both do the same job but an External Interrupt has its own interrupt vector. PinChangeInterrupts share one vector for several pins.

The CPU will be able to respond slightly faster to an External Interrupt because it doesn't have to check where the interrupt came from.

INT0 is PCINT 18
and
INT1 is PCINT 19

PCINT 18 and PCINT 19 are included in PCINT [23:0] !

It is not true. INT0/1 have self interrupt vector each, with higher priority than pin change. Pin change interrupt is common for the group of pins on ATmega328P for example. External and pin change interrupts they can the same fuctionality. Main differences are
that external interrupt is generated from exact and the only pin and pin change interrupt is generated from any of pins within group.

But they are also configured with EICRA and EIMSK register ! wich is very strange and confusing!

Strange? You need some way to configure it.

If an interrupt occurs on pin PB7 wich is also PCINT 7 , PCIF0 in PCIFR register is set to 1.
So I know an interrupt has occurred on one of the goup PB7:PB0 pin. But How do I know exactly on what pin it has occured ?

You have test it.

hary:
So I know an interrupt has occurred on one of the goup PB7:PB0 pin. But How do I know exactly on what pin it has occured ?

Your program has to figure it out by looking at the status bits.

But they are also configured with EICRA and EIMSK register ! wich is very strange and confusing!

Strange? You need some way to configure it.

int0 is enabled with INT0 of EIMSK register
int1 is enabled with INT1 of EIMSK register
like this
EIMSK |= (1<<INT0) | (1<<INT1)

But int0 and int1 are also pin 18 and 19. And these pin can also be enable/disable with the register PCMSK2, like this :
PCMSK2 |= (1<<PCINT18) | (1<<PCINT19)

Whathapen if :

EIMSK |= (1<<INT0) | (1<<INT1)
PCMSK2 &= ~(1<<PCINT18)
PCMSK2 &= ~(1<<PCINT19)

Are int0 (pin18) and int1 (pin19) enable or not ?

That's what I meant

hary:
Whathapen if :

EIMSK |= (1<<INT0) | (1<<INT1)
PCMSK2 &= ~(1<<PCINT18)
PCMSK2 &= ~(1<<PCINT19)

Are int0 (pin18) and int1 (pin19) enable or not ?

Yes, you'll get two interrupts from the same signal.

fungus:

hary:
Whathapen if :

EIMSK |= (1<<INT0) | (1<<INT1)
PCMSK2 &= ~(1<<PCINT18)
PCMSK2 &= ~(1<<PCINT19)

Are int0 (pin18) and int1 (pin19) enable or not ?

Yes, you'll get two interrupts from the same signal.

2 interrupt even if INT0 is enable and PCINT18 is disable ? What a mess to deal with ! No way I'll be able to make a clean and working code once this way !
uC are really tricky !

hary:
2 interrupt even if INT0 is enable and PCINT18 is disable ? What a mess to deal with ! No way I'll be able to make a clean and working code once this way !

Oh, you disabled some, I thought you enabled them all. My bad. You only get the interrupts you enable.

Can you get two interrupts from the same signal? Yes, but you're in control so it's up to you to not do that...

hary:
uC are really tricky !

But uC are also very logical.

So with this code :

EIMSK |= (1<<INT0) 
PCMSK2 &= ~(1<<PCINT18)

I've got only 1 interrupt and I know the interrupt comes from pin 18 immediately.

Thanks, I got it a little bit more clear now.