Skip to content

Commit c6233b1

Browse files
authored
SAMD51: More reliable Servo/BLTouch PWM (#18710)
1 parent 805fb4c commit c6233b1

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

Marlin/src/HAL/SAMD51/timers.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
// --------------------------------------------------------------------------
2424
// Includes
2525
// --------------------------------------------------------------------------
26+
2627
#include "../../inc/MarlinConfig.h"
28+
#include "ServoTimers.h" // for SERVO_TC
2729

2830
// --------------------------------------------------------------------------
2931
// Local defines
@@ -39,7 +41,7 @@ const tTimerConfig TimerConfig[NUM_HARDWARE_TIMERS+1] = {
3941
{ {.pTc=TC0}, TC0_IRQn, TC_PRIORITY(0) }, // 0 - stepper (assigned priority 2)
4042
{ {.pTc=TC1}, TC1_IRQn, TC_PRIORITY(1) }, // 1 - stepper (needed by 32 bit timers)
4143
{ {.pTc=TC2}, TC2_IRQn, 5 }, // 2 - tone (reserved by framework and fixed assigned priority 5)
42-
{ {.pTc=TC3}, TC3_IRQn, TC_PRIORITY(3) }, // 3 - servo (no interrupts used)
44+
{ {.pTc=TC3}, TC3_IRQn, TC_PRIORITY(3) }, // 3 - servo (assigned priority 1)
4345
{ {.pTc=TC4}, TC4_IRQn, TC_PRIORITY(4) }, // 4 - software serial (no interrupts used)
4446
{ {.pTc=TC5}, TC5_IRQn, TC_PRIORITY(5) },
4547
{ {.pTc=TC6}, TC6_IRQn, TC_PRIORITY(6) },

Marlin/src/HAL/SAMD51/timers.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ typedef uint32_t hal_timer_t;
5959
#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(TEMP_TIMER_NUM)
6060
#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(TEMP_TIMER_NUM)
6161

62-
#define TC_PRIORITY(t) (t == STEP_TIMER_NUM || t == PULSE_TIMER_NUM) ? 2 \
63-
: (t == TEMP_TIMER_NUM) ? 6 \
62+
#define TC_PRIORITY(t) t == SERVO_TC ? 1 \
63+
: (t == STEP_TIMER_NUM || t == PULSE_TIMER_NUM) ? 2 \
64+
: (t == TEMP_TIMER_NUM) ? 6 \
6465
: 7
6566

6667
#define _TC_HANDLER(t) void TC##t##_Handler()

0 commit comments

Comments
 (0)