Hello,
I am trying to get a very simple sketch running, but ...failing ![]()
I want to measure the frequency with the WEMOD1 mini coming to the pin 4 by external interrupt . The two rising edges are measured so far correct, but I want to get the difference calculated. And this doesn't work...
I am running out of ideas...
volatile unsigned long saveMicros, previousMicros, currentMicros, frequency, duration;
void setup() {
 Serial.begin(115200);
 attachInterrupt(digitalPinToInterrupt(4), IntCallback, RISING);
 delay(10);
}
void loop() {
 Serial.print("prev: ");
 Serial.print(previousMicros);
 Serial.print(" curr:");
 Serial.print(currentMicros);
 Serial.print(" delta:");
 Serial.println(duration);
}
void IntCallback() {
 previousMicros = currentMicros;
 currentMicros = micros();
 duration = ( previousMicros - currentMicros );
}
And the serial monitor gives results like that:
prev: 7559521 curr:7560820 delta:4294966967 <--- Whaaaat?
prev: 7563423 curr:7565208 delta:4294967016
prev: 7567752 curr:7569254 delta:4294966968
prev: 7571537 curr:7573159 delta:4294967002