ArduinoCore-samd icon indicating copy to clipboard operation
ArduinoCore-samd copied to clipboard

Fix some wrong register values

Open wh201906 opened this issue 2 years ago • 1 comments

The function setPeriod() sets the wrong register value. According to the comment, these timer library is inspired on the khoih-prog/SAMD_TimerInterrupt, which has the right code.

For TC3: https://github.com/khoih-prog/SAMD_TimerInterrupt/blob/88c4a730ce3396cdf71f69936d24e6eb0d7f9b0a/src/SAMDTimerInterrupt.hpp#L424-L430 https://github.com/khoih-prog/SAMD_TimerInterrupt/blob/88c4a730ce3396cdf71f69936d24e6eb0d7f9b0a/src/SAMDTimerInterrupt.hpp#L724-L730 For TCC: https://github.com/khoih-prog/SAMD_TimerInterrupt/blob/88c4a730ce3396cdf71f69936d24e6eb0d7f9b0a/src/SAMDTimerInterrupt.hpp#L810-L812

wh201906 avatar May 05 '23 09:05 wh201906

The formula for the timer period can also be found in the datasheet DS40001882D


30.6.2.6.3 图片


31.6.2.5.5 图片


In the current code, the +1 is ignored, so the register value is wrong.

wh201906 avatar May 05 '23 09:05 wh201906