I've done my homework reading the datasheet, but I am to stupid to be 100% sure that I understand it right, thus I seek help from those kind enough to bare with my yawning.
To back up a bit... I have an application where I want to count events that have a much slower repetition rate than my loop function. Plus, they are burdoned with the so called debouncing effect - I use a mechanical switch.
With that conditions I decided I might check the PCIF2 bit of the PCIFR register every time I enter the loop. In principle if it is set to 1 it means that I had an "interrupt requsest" which I assume means that the input pin has changed it state...physically. I'll just copy - paste the relevant text for refeence. This is from the ATmega328 & friends manual.
Bit 2 – PCIF2: Pin Change Interrupt Flag 2 When a logic change on any PCINT[23:16] pin triggers an interrupt request, PCIF2 becomes set (one). If the I-bit in SREG and the PCIE2 bit in PCICR are set (one), the MCU will jump to the corresponding Interrupt Vector. The flag is cleared when the interrupt routine is executed. Alter- natively, the flag can be cleared by writing a logical one to it
OK, reading on it sayt that MCU will jump to the corresponding interrupt vector... but what is the condition for the jump?? Innitialy I thought it was a defined interrupt routine , plus ofcourse appropriate SREG and PCICR bits, but it seems only the latter two conditions suffice. So to use the Flag register to measure my switch..ehm switching I actuall have to disable the PCIE2 in the PCICR register and only set the appropriate bit in the PCIMSK to 1.??? Because otherwise "The flag is cleared when the interrupt routine is executed. " and I miss it when I check it in the main loop.
OK, that kind of works, I would just like a confirmation of someone more knowledgable.
One other question: I rely on newsoft serial which uses pins on the same pin change interrupt bank (but of course different pin). Will that interfere with my pin...I don't know what newsoft serial will do with my mask settings!?!