First I love this library! Given the SAMD51 docs and all the config options, and how those end up being presented in Arduino/Wire, it's a bit of a soup. This library makes all that dramatically easier.
Since I needed multiple timers I ended up having to change the library around for my own needs though it's mostly just changing which timers I'm using. Notably though I found that changing the input from long to float for the setPeriod function avoided some stairstep/cliffs I was getting due to rounding erros.
There's already floating point math happening here:
int compareValue = (int)(GCLK1_HZ / (prescaler/((float)period / 1000000))) - 1;
So my suggestion is to basically make the period a float as input.
I did that to my customized version of the lib and it made a substantial difference to my application (which involves variable clocking the DAC for audio output).
First I love this library! Given the SAMD51 docs and all the config options, and how those end up being presented in Arduino/Wire, it's a bit of a soup. This library makes all that dramatically easier.
Since I needed multiple timers I ended up having to change the library around for my own needs though it's mostly just changing which timers I'm using. Notably though I found that changing the input from
longtofloatfor the setPeriod function avoided some stairstep/cliffs I was getting due to rounding erros.There's already floating point math happening here:
So my suggestion is to basically make the period a float as input.
I did that to my customized version of the lib and it made a substantial difference to my application (which involves variable clocking the DAC for audio output).