External interrupts enabling (code understanding)

Hi there!
can anyone please help me to understand these lines which enables the External interrupts on Arduino mega 2560?

  PCICR |= (1 << PCIE0);   
  PCMSK0 |= (1 << PCINT0); 
  PCMSK0 |= (1 << PCINT1);  
  PCMSK0 |= (1 << PCINT2);  
  PCMSK0 |= (1 << PCINT3);

I m not able to understand the purpose of <<and |= in PCMSK0 |= 1 << PCINT0.
I know its a stupid question but Im a newbie.
Bundle of thanks

Look up Bitwise Operators and Assignment Operators in Code/Statements/Variables/Operators

Whandall:
Look up Bitwise Operators and Assignment Operators in Code/Statements/Variables/Operators

I know the working of bit shifts and assignment operators. but when it comes to PCMSK0 |= 1 << PCINT0 I dont know how PCINT0 is shifted left when this bit present in PCICR register while we are bitwise ORing it with PCMSK0 register.

Sorry for the misunderstanding, as you not stated to be familiar with the operators.

It is the 1 that is shifted to the position named PCINT0.
Then it is ored to the mask-register content and written back.

ahsanraza:
I know the working of bit shifts and assignment operators. but when it comes to PCMSK0 |= 1 << PCINT0 I dont know how PCINT0 is shifted left when this bit present in PCICR register while we are bitwise ORing it with PCMSK0 register.

PCINT0 is defined somewhere to be 1 or 2 or 3 or whatever bit in the PCMSK0 register it is. There are defined like that for all the named bits in the named registers. So this reduces to:

PCMSK0 |= 1 << 3

assuming PCINT0 was the third bit of PCMSK0. I’m too lazy to look up which one it actually is. But you get the point.

Thanks All. I get the point :slight_smile: Thanks again.