diff options
| author | Scott Shawcroft <scott@adafruit.com> | 2021-01-11 15:33:59 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-11 15:33:59 -0800 |
| commit | 10093d37c578d3302ce8e271badfad43fe0a56ec (patch) | |
| tree | aa8a1b4a1dc8816714f4ae9e1a9e232038d07fb7 /ports | |
| parent | a92712acc573c206bbcd5adcc92d32b62f23df7e (diff) | |
| parent | 908e02439d79b7dd9d29f7465833aead504c257c (diff) | |
Merge pull request #3960 from dhalbert/pwmout-tcc-resolution
Look up TCC resolution as necessary
Diffstat (limited to 'ports')
| -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; |
