I am trying to count the pulses of an external device with this simple sketch:
#define cpmPin 3
int count = 0;
void ICACHE_RAM_ATTR impulseCount(void) {
count++;
}
void setup() {
Serial.begin(115200);
Serial.println("Setup");
pinMode(cpmPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(cpmPin), impulseCount, FALLING);
Serial.println("End Setup");
}
void loop() {
Serial.print("Count: ");
Serial.println(count);
delay(5000);
}
The counter does not increment whatever happens on pin 3.
Just to ensure my board was not failing with pin 3, I changed to pin 6 and got every 5 seconds:
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 3460, room 16
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4
tail 4
chksum 0xc9
csum 0xc9
v00042070
~ld
Setup
Am I doing something wrong?