There is an ingenious library that wraps the timer programming up in an easy to use way
https://build.particle.io/libs/SparkIntervalTimer/1.3.7
And I’d count the sensor revolutions (and measure the speed) this way
#include "SparkIntervalTimer.h"
IntervalTimer msTimer;
volatile uint32_t usLastTime = 0;
volatile uint32_t usDeltaTime = 0;
volatile uint32_t msCount = 0;
volatile double revPerSec = 0;
volatile double revPerMS = 0;
void msISR() {
revPerMS = msCount;
msCount = 0;
}
void senseISR() {
uint32_t us = micros();
msCount++;
usDeltaTime = us - usLastTime;
usLastTime = us;
revPerSec = 1000000.0 / usDeltaTime;
}
void setup() {
...
msTimer.begin(msISR, 1000, uSec); // trigger every 1000µs
pinMode(FLOWSENSORPIN, INPUT_PULLUP);
attachInterrupt(FLOWSENSORPIN, senseISR, FALLING);
...
}