diff options
| author | Scott Shawcroft <scott.shawcroft@gmail.com> | 2017-06-09 17:16:33 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott.shawcroft@gmail.com> | 2017-06-09 17:16:33 -0700 |
| commit | 736a63e85a331ebcfdbfe6210b1d39569fb330c9 (patch) | |
| tree | 2eaec0885529927aa41f21a9542b4c71817a1df7 | |
| parent | 3658c922708109effce79864046581d1c8d927e7 (diff) | |
atmel-samd: Set up the tcc_instance when using an already active TCC.
This fixes a hard lock that happens when using a second channel on an
in use TCC. The lock occurred when setting the duty cycle on the channel
because the hw address was not available to ASF.
Thanks to @ladyada for finding the bug.
| -rw-r--r-- | atmel-samd/common-hal/pulseio/PWMOut.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/atmel-samd/common-hal/pulseio/PWMOut.c b/atmel-samd/common-hal/pulseio/PWMOut.c index a98bf37ad..336948a2e 100644 --- a/atmel-samd/common-hal/pulseio/PWMOut.c +++ b/atmel-samd/common-hal/pulseio/PWMOut.c @@ -128,6 +128,8 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, channel_ok(&pin->primary_timer, primary_timer_index)) { t = &pin->primary_timer; index = primary_timer_index; + self->tcc_instance.hw = t->tcc; + self->tcc_instance.double_buffering_enabled = true; } else if (!variable_frequency && secondary_timer_index != 0xff && target_timer_frequencies[secondary_timer_index] == frequency && @@ -135,6 +137,8 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, channel_ok(&pin->secondary_timer, secondary_timer_index)) { t = &pin->secondary_timer; index = secondary_timer_index; + self->tcc_instance.hw = t->tcc; + self->tcc_instance.double_buffering_enabled = true; } else { // Pick an unused timer if available. |
