I'm noticing a crash when testing out some interrupt code for a project I'm working on.
I've returned to the example provided with the library PciManager and I'm still experiencing the same issue. There doesn't appear to be any patten to when the crash appears, and on occasion I've been playing for several minutes and not seen a crash. NOTE I had to add a file (Task.h) from the developers other project (SoftTimer) to get it to compile.
here is the code:
#include <PciManager.h>
#include <PciListenerImp.h>
#define INPUT_PIN 3
PciListenerImp listener(INPUT_PIN, onPinChange);
int i = 0;
void setup() {
Serial.begin(9600);
PciManager.registerListener(INPUT_PIN, &listener);
Serial.println("Ready.");
}
void onPinChange(byte changeKind) {
i++;
Serial.print("pci : ");
Serial.print(i);
Serial.print(" : ");
Serial.println(changeKind);
}
void loop() { }
I have a wire connected to pin 3 and 3.3v which I'm pulling out and then connecting again. Some times when disconnected it continually interrupts, I was expecting this. Sometimes it doesn't which I found strange, the crash appears to happen more in the latter case.
Here is a trace from the serial monitor
Ready.
pci : 1 : 0
pci : 2 : 1
pci : 3 : 0
pci : 4 : 1
pci : 5 : 0
pci : 6 : 1
pci : 7 : 0
pci : 8 : 1
pci : 9 : 0
pci : 10 : 1
pci : 11 : 0
pci : 12 : 1
pci : 13 : 0
pci : 14 : 1
pci : 15 : 0
pci : 16 : 1
pci : 17 : 0
pci : 18 : 1
pci : 19 : 0
pci : 20 : 1
pci :
I've run this on a shrimp and on a freeduino diecimila compatible board both resulting in the same effect.
Anyway down to question; is the issue the way I'm interrupting? i.e. not stopping the floating pin? or is it a problem with the library, or is it a fundamental problem with pin change interrupts.