Fix for off-by-one in get_max_duty()#959
Conversation
|
Thanks @codepainters. However I would suggest, if we want the functions to keep returning |
|
Hmm, fair point. Actually it's quite interesting what the chip actually do if 0 is used as a duty cycle value, let me check the datasheet (and perhaps the hardware). |
|
Finally found a moment to take a look, I've done some experiments with ItsyBits M4. I've tried setting maximum period (2^16 1) and try various duty cycle values (
So, with maximum period value it is not possible to get 100% PWM. All that said, I guess that saturating add is a good approach here (the configuration with maximum period is somewhat pathological anyway). |
|
Sounds good, if you just want to make that change, I can get this merged. |
|
Just added Note: I only added |
72278d2 to
ef8dc3e
Compare
Summary
This PR fixes off-by-one issue in TC/TCC
get_max_duty()function, for details see #911.Change verified with Adafruit ItsiBitsy M4 and Sparkfun ATSAMD21G Mini boards.