diff options
| author | Dan Halbert <halbert@halwitz.org> | 2021-01-09 15:04:23 -0500 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2021-01-09 15:04:23 -0500 |
| commit | 908e02439d79b7dd9d29f7465833aead504c257c (patch) | |
| tree | 1f2c5bcdc436eaf132b31be7cab6809831036a2d | |
| parent | 55c80754c76a115e2f128931a408e6702aee6ef4 (diff) | |
Look up TCC resolution as necessary
| -rw-r--r-- | ports/atmel-samd/common-hal/pwmio/PWMOut.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ports/atmel-samd/common-hal/pwmio/PWMOut.c b/ports/atmel-samd/common-hal/pwmio/PWMOut.c index 2e538ccdc..b5142c21e 100644 --- a/ports/atmel-samd/common-hal/pwmio/PWMOut.c +++ b/ports/atmel-samd/common-hal/pwmio/PWMOut.c @@ -44,6 +44,7 @@ # define _TCC_SIZE(unused, n) TCC ## n ## _SIZE, # define TCC_SIZES { REPEAT_MACRO(_TCC_SIZE, 0, TCC_INST_NUM) } +static const uint8_t tcc_sizes[TCC_INST_NUM] = TCC_SIZES; static uint32_t tcc_periods[TCC_INST_NUM]; static uint32_t tc_periods[TC_INST_NUM]; @@ -233,8 +234,7 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self, resolution = 16; } else { // TCC resolution varies so look it up. - const uint8_t _tcc_sizes[TCC_INST_NUM] = TCC_SIZES; - resolution = _tcc_sizes[timer->index]; + resolution = tcc_sizes[timer->index]; } // First determine the divisor that gets us the highest resolution. uint32_t system_clock = common_hal_mcu_processor_get_frequency(); @@ -421,7 +421,8 @@ void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t* self, if (t->is_tc) { resolution = 16; } else { - resolution = 24; + // TCC resolution varies so look it up. + resolution = tcc_sizes[t->index]; } uint32_t system_clock = common_hal_mcu_processor_get_frequency(); uint32_t new_top; |
