Audience is teens being introduced to INTs and PCINTs.
I had found some things in the datasheet last night:
(0x68) PCICR – – – – – PCIE2 PCIE1 PCIE0
0x1B (0x3B) PCIFR – – – – – PCIF2 PCIF1 PCIF0
What I missed was this, even tho it was in the same area:
(0x6D) PCMSK2 PCINT23 PCINT22 PCINT21 PCINT20 PCINT19 PCINT18 PCINT17 PCINT16
on page 520
The use of _BV in the code was not at all clear, google searching found lots of explanations involving things like (name<<1), and which was ‘better’ due to writing fewer characters, vs how much shifting was needed to get a bit into position.
Now that I know what its doing, I’d just as soon write it this way, which I find clearer, and I would think would perform quicker, but haven’t looked at compiled code to actually confirm:
PCMSK2 = _BV (PCINT4) | _BV (PCINT5);
PCMSK2 = PCMSK2 | B00110000; // set bits for PCINT21, 20 in PinChangeMask2 (PCINTs 23 to 16)
PCIFR = _BV (PCIF2) ;
PCIFR = PCIFR | B00000100; // write 1 to clear any interrupts for PCMSK2 in Pin Change Interrupt Flag Register
PCICR |= _BV (PCIE2) ;
PCICR = PCICR | B00000100; // enable PCINTs for PCMSK2 in Pin Change Interrupt Configuration(?) Register
But that’s just me, coming at this as hardware engineer and not a software engineer.