Skip to content

Commit 908e024

Browse files
committed
Look up TCC resolution as necessary
1 parent 55c8075 commit 908e024

File tree

1 file changed

+4
-3
lines changed
  • ports/atmel-samd/common-hal/pwmio

1 file changed

+4
-3
lines changed

ports/atmel-samd/common-hal/pwmio/PWMOut.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
# define _TCC_SIZE(unused, n) TCC ## n ## _SIZE,
4646
# define TCC_SIZES { REPEAT_MACRO(_TCC_SIZE, 0, TCC_INST_NUM) }
47+
static const uint8_t tcc_sizes[TCC_INST_NUM] = TCC_SIZES;
4748

4849
static uint32_t tcc_periods[TCC_INST_NUM];
4950
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,
233234
resolution = 16;
234235
} else {
235236
// TCC resolution varies so look it up.
236-
const uint8_t _tcc_sizes[TCC_INST_NUM] = TCC_SIZES;
237-
resolution = _tcc_sizes[timer->index];
237+
resolution = tcc_sizes[timer->index];
238238
}
239239
// First determine the divisor that gets us the highest resolution.
240240
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,
421421
if (t->is_tc) {
422422
resolution = 16;
423423
} else {
424-
resolution = 24;
424+
// TCC resolution varies so look it up.
425+
resolution = tcc_sizes[t->index];
425426
}
426427
uint32_t system_clock = common_hal_mcu_processor_get_frequency();
427428
uint32_t new_top;

0 commit comments

Comments
 (0)