@@ -71,13 +71,14 @@ void Servo_Handler(const timer16_Sequence_t timer, Tc *pTc, const uint8_t channe
7171#endif
7272
7373void Servo_Handler (const timer16_Sequence_t timer, Tc *tc, const uint8_t channel) {
74+ tc->TC_CHANNEL [channel].TC_SR ; // clear interrupt
75+
7476 const bool good_servo = SERVO_INDEX (timer, Channel[timer]) < ServoCount;
7577 if (Channel[timer] < 0 )
7678 tc->TC_CHANNEL [channel].TC_CCR |= TC_CCR_SWTRG; // channel set to -1 indicated that refresh interval completed so reset the timer
77- else if (good_servo)
79+ else if (good_servo && SERVO (timer, Channel[timer]). Pin . isActive )
7880 extDigitalWrite (SERVO (timer, Channel[timer]).Pin .nbr , LOW); // always pulse the channel low
7981
80- tc->TC_CHANNEL [channel].TC_SR ; // clear interrupt
8182
8283 Channel[timer]++; // increment to the next channel
8384 if (good_servo && Channel[timer] < SERVOS_PER_TIMER) {
@@ -98,7 +99,7 @@ void Servo_Handler(const timer16_Sequence_t timer, Tc *tc, const uint8_t channel
9899static void _initISR (Tc *tc, uint32_t channel, uint32_t id, IRQn_Type irqn) {
99100 pmc_enable_periph_clk (id);
100101 TC_Configure (tc, channel,
101- TC_CMR_TCCLKS_TIMER_CLOCK3 | // MCK/32
102+ TC_CMR_TCCLKS_TIMER_CLOCK1 | // MCK/32
102103 TC_CMR_WAVE | // Waveform mode
103104 TC_CMR_WAVSEL_UP_RC ); // Counter running up and reset when equals to RC
104105
0 commit comments