I think TimerTC3 has a bug.
I tried TimerTc3.initialize 10922 → 10923 and 10923 → 10922 in order.
Then the timer slowed down.
ex.
08:25:40.101 → CountUp:10922
08:25:40.101 → CountUp:10922
08:25:40.135 → CountUp:10922
08:25:40.135 → CountUp:10922
08:25:40.821 → CountUp:10923 <= +686msec
08:25:41.543 → CountUp:10923 <= +722msec
08:25:42.234 → CountUp:10923 <= +691msec
08:41:01.160 → CountUp:10923
08:41:01.160 → CountUp:10923
08:41:01.194 → CountUp:10923
08:41:01.194 → CountUp:10923
08:41:02.605 → CountUp:10922 <= +1.411sec
08:41:04.010 → CountUp:10922 <= +1.405sec
08:41:05.386 → CountUp:10922 <= +1.376sec
Setting from 10922 or less to 10923 or more or from 10923 or more to 10922 or less is NG ?
#include <Arduino.h>
#include <TimerTC3.h>
uint32_t tc_time = 10920;
int count = 0;
void setup()
{
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
TimerTc3.initialize(tc_time);
TimerTc3.attachInterrupt(int_timer);
Serial.println("Start");
}
void loop()
{
delay(10);
}
void int_timer()
{
Serial.print("CountUp:");
Serial.println(tc_time);
if(++count >= 10)
{
tc_time++;
TimerTc3.stop();
TimerTc3.initialize(tc_time);
TimerTc3.attachInterrupt(int_timer);
count = 0;
}
}