Mega 2560 interrupt mapping

I am trying to get 2 encoders to work with a Mega 2560 board. Using pin change interrupts works fine with the uno board but unsuccessful with Mega. It appears to be a mapping problem in that the Mega ports are different. The attached code should work on either board but does not. I inserted print commands just to test for the interrupt with no success. Only one interrupt works on the Mega. Any help will be appreciated.

// Install Pin change interrupt for a pin, can be called multiple times
int Brake_Encoder_Count;
int Mark5_Encoder_Count;
void pciSetup(byte pin)
{
  *digitalPinToPCMSK(pin) |= bit (digitalPinToPCMSKbit(pin));  // enable pin
  PCIFR  |= bit (digitalPinToPCICRbit(pin)); // clear any outstanding interrupt
  PCICR  |= bit (digitalPinToPCICRbit(pin)); // enable interrupt for the group
}

// Use one Routine to handle each group

ISR (PCINT0_vect) // handle pin change interrupt for D8 to D13 here
{
    
  if ( bitRead(PINB, 6) == bitRead(PINB, 7)) //Pins 12 & 13

  {
    Brake_Encoder_Count++;
  }
  else
  {
    Brake_Encoder_Count--;
  }
}

ISR (PCINT1_vect)
{
  Serial.print(" PCINT1_vect");
/*
  if ( bitRead(PINB, 4) == bitRead(PINB, 5)) //Pins 14 & 15

  {
    Mark5_Encoder_Count++;
  }
  else
  {
    Mark5_Encoder_Count--;
  }*/
}

ISR (PCINT2_vect) // handle pin change interrupt for D0 to D7 here
{
  Serial.print(" PCINT2_vect");
 /* if ( bitRead(PINB, 4) == bitRead(PINB, 5)) //Pins 14 & 15

  {
    Mark5_Encoder_Count++;
  }
  else
  {
    Mark5_Encoder_Count--;
  }*/
}

void setup() {
  int i;
  Serial.begin(9600);

  // set pullups, if necessary
  for (i = 0; i <= 15; i++)
    digitalWrite(i, HIGH); // pinMode( ,INPUT) is default

  for (i = A0; i <= A5; i++)
    digitalWrite(i, HIGH);

  // enable interrupt for pin...
  pciSetup(13);
  pciSetup(6);
  pciSetup(7);
  pciSetup(14);
  pciSetup(15);
  pciSetup(A8);
}


void loop() {
  // Nothing needed
  Serial.print("Brake_Encoder_Count   ");Serial.println(Brake_Encoder_Count);
  Serial.println(Mark5_Encoder_Count);
  delay(200);
}

I think there are some pins on a Mega that do not have pinChange interrupts. Maybe you have accidentally stumbled on them? Have a look at the Atmega 2560 datasheet.

...R

I have looked at the data sheet and the pins that I selected are PCINT pins by the data sheet. On the UNO (PCINTx_vect) match the port mapping. I don't find any designation on the Mega for PCINTx_vect. My assumption is that PCINT0_vect maps to PCINT0 thur PCINT7, PCINT1_vect to PCINT8 thur 15 and PCINT2_vect does 16 to 23. Is this a correct assumption?

Robin2:
I think there are some pins on a Mega that do not have pinChange interrupts. Maybe you have accidentally stumbled on them? Have a look at the Atmega 2560 datasheet.

...R

Thanks Robin2 and sherzaad, That was exactly the information I needed. I'm learning how to use the interrupts, I'd found code for the UNO that won't work on the Mega. After reading your posts I have the code working and have a better understanding.

Thanks for the update.

...R