You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 29, 2023. It is now read-only.
If I set a interval greater than 20000us and then set a smaller than 20000us, I'll have my period 4 times bigger than expected.
Steps to Reproduce
SAMDTimer ITimer(TIMER_TC3);
uint32_t myClockTimer=0,lastMicros=0;
void clock(void)
{
myClockTimer=micros()-lastMicros; //2us come from here
lastMicros=micros();
}
void setup() {
}
void loop(){
ITimer.attachInterruptInterval(20005, clock); //myClockTimer=20003 (20005 minus 2us, it's correct)
delay(5000);
ITimer.attachInterruptInterval(19995, clock); //myClockTimer=79978(4 times bigger than expected, minus 2us)
delay(5000);
}
Expected behavior
The expected behavior was a timer period of 19995us.
Actual behavior
The actual behavior was a timer period 4 times bigger.
Information
Arduino Core v1.8.9
Atmel Studio
Some observations
If I start with 19000us, works fine. Then I go to 21000us, works fine. When I go back to 19000us, the bug happen.
Only noticed when going from a bigger(>20000) to smaller(<20000). And since this happen the smaller won't work anymore.
I'm suspecting some bug with the preScaler.