@peekay123, I haven’t found this mentioned anywhere but when I use the SparkIntervalTimer, it seems that I run into a lower limit on ISR execution every 5ms. Is that correct? Is there anyway to get around this? I was hoping to execute it every 500us.
In this stripped code, a value of 9 (4.5ms) in this command doesn’t seem to execute the ISR:
myTimer.begin(Sample, 9, hmSec);
But a value of 10 does work. My goal was a value of 1…
#include "SparkIntervalTimer.h"
#define PUBLISH_TIME 3000 // 1000ms = every second
IntervalTimer myTimer;
// for now...all these are global
unsigned long currentMillis, prior_publish_time;
bool timer_started = false;
volatile unsigned long currentMillisx[8];
void Sample(void);
void setup() {
}
void loop() {
currentMillis = millis();
if (!timer_started) {
myTimer.begin(Sample, 9, hmSec);
timer_started = true;
}
// Print the most recent buffer
if ((currentMillis - prior_publish_time) >= PUBLISH_TIME) {
for(int i = 0; i < 8; i++){
Serial.printlnf("%lu",currentMillisx[i]);
}
Serial.printlnf("");
prior_publish_time = currentMillis;
}
}
void Sample(void) {
static int counter = 0;
currentMillisx[counter] = millis();
if (counter < 7) counter++;
else counter = 0;
}
SAMPLE OUTPUT with value of 10 which corresponds to ISR execution every 5ms ( (with 9 or less, all show up as 0)
9050
9055
9017
9022
9028
9033
9039
9044
12042
12047
12053
12014
12020
12025
12031
12036