I am using a mega169 to read 7 toggle switch lines on port E. The port is initialized like this:
DDRE = 0; // Port E is switch inputs PCMSK0 = 0xff; // all pins of Port E generate interrupts
The pin change interrupt register is set up like this:
EIFR = 0xff; EIMSK = 1<<PCIE0; // allow interrupts from pin changes on port E
My problem is that sometimes the interrupts are generated, and sometimes not, and I cannot find any kind of condition that affects this.
The switches are set up in a NO configuration, and the inputs of the port are pulled to ground via 47K resistors. When the switch is "active" it pulls the port pin to VCC. Rise times are in the nsec region (about 4ns, according to my scope). I cannot find anywhere in the ATmega169 data sheet whether the PCINT pins are level or edge driven, but either way, I should be OK. Scope shows that pins are at ground when off, and go to VCC when switch is activated. It does not seem to be pin specific; I can switch virtually any switch and get several times in a row where no interrupt is generated, then several times when it isn't, then it will work again. At this point, I'm clueless.