//Serial.print("PINB "); Serial.print(PINB); //Read port values for test only
//digitalWrite(ledGreen,!digitalRead(ledGreen)); //for test only
}
and it works.
the problem is when i re-enable it after few seconds some times the interrupt occur again, only one after enabling it without touching the switch.
I also see that PCIFR = 0 when it enters the ISR.
if then I will enable it again and will not touch the switch anymore the interrupt will not occur.
I switch input is configured to use the internal pull-up.
It is not allowed to use Serial.print (or any other Serial function) inside an ISR. That might have strange results, like you have.
Changing the interrupt bits inside an ISR is dangerous of course. I can not tell if that will work, I would have to read large parts of the datasheet about all the interrupt flags.
Could you have a broader view at your project ? Why do you want to read a switch that way. Could you use polling, or perhaps the debounce library.
Interrupts are great for communication with other devices, or interrupts from sensors, or special hardware. But a simple button doesn't require that. At least, I never had to use an interrupt for a simple switch or button.