Skip to content

Commit e7a6c77

Browse files
Resolve DUE Servo pulse issue
1 parent 3e9fb34 commit e7a6c77

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Marlin/src/HAL/DUE/Servo.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,15 @@ void Servo_Handler(timer16_Sequence_t timer, Tc *pTc, uint8_t channel);
7171
#endif
7272

7373
void Servo_Handler(timer16_Sequence_t timer, Tc *tc, uint8_t channel) {
74-
// clear interrupt
75-
tc->TC_CHANNEL[channel].TC_SR;
7674
if (Channel[timer] < 0)
7775
tc->TC_CHANNEL[channel].TC_CCR |= TC_CCR_SWTRG; // channel set to -1 indicated that refresh interval completed so reset the timer
78-
else if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && SERVO(timer, Channel[timer]).Pin.isActive)
76+
else {
77+
//else if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && SERVO(timer, Channel[timer]).Pin.isActive)
7978
extDigitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, LOW); // pulse this channel low if activated
79+
}
80+
81+
// clear interrupt
82+
tc->TC_CHANNEL[channel].TC_SR;
8083

8184
Channel[timer]++; // increment to the next channel
8285
if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
@@ -92,6 +95,7 @@ void Servo_Handler(timer16_Sequence_t timer, Tc *tc, uint8_t channel) {
9295
: tc->TC_CHANNEL[channel].TC_CV + 4; // at least REFRESH_INTERVAL has elapsed
9396
Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel
9497
}
98+
9599
}
96100

97101
static void _initISR(Tc *tc, uint32_t channel, uint32_t id, IRQn_Type irqn) {

0 commit comments

Comments
 (0)