From 3658c922708109effce79864046581d1c8d927e7 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 9 Jun 2017 17:15:31 -0700 Subject: [PATCH] atmel-samd: Reset TCC channel in use array on reset. This fixes spurious "All timers in use" exceptions. Thanks to @ladyada for finding this issue. --- atmel-samd/common-hal/pulseio/PWMOut.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/atmel-samd/common-hal/pulseio/PWMOut.c b/atmel-samd/common-hal/pulseio/PWMOut.c index ff61965a75..a98bf37ad0 100644 --- a/atmel-samd/common-hal/pulseio/PWMOut.c +++ b/atmel-samd/common-hal/pulseio/PWMOut.c @@ -64,6 +64,12 @@ void pwmout_reset(void) { while (tccs[i]->SYNCBUSY.bit.ENABLE == 1) { } } + // TODO(tannewt): Make this depend on the CMSIS. + if (i == 0) { + tcc_channels[i] = 0xf0; + } else { + tcc_channels[i] = 0xfc; + } tccs[i]->CTRLA.bit.SWRST = 1; } Tc *tcs[TC_INST_NUM] = TC_INSTS;