Skip to content

Commit 1e9a669

Browse files
author
ladyada
committed
change Tone on samd51 to be TC0 so we can use higher numbers for other stuff! (servo is TC1)
1 parent e204bf3 commit 1e9a669

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cores/arduino/Tone.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ volatile bool toneIsActive = false;
3737
volatile bool firstTimeRunning = false;
3838

3939
#if defined(__SAMD51__)
40-
#define TONE_TC TC2
41-
#define TONE_TC_IRQn TC2_IRQn
42-
#define TONE_TC_GCLK_ID TC2_GCLK_ID
40+
#define TONE_TC TC0
41+
#define TONE_TC_IRQn TC0_IRQn
42+
#define TONE_TC_GCLK_ID TC0_GCLK_ID
4343
#else
4444
#define TONE_TC TC5
4545
#define TONE_TC_IRQn TC5_IRQn
@@ -48,7 +48,7 @@ volatile bool firstTimeRunning = false;
4848
#define TONE_TC_CHANNEL 0
4949

5050
#if defined(__SAMD51__)
51-
void TC2_Handler (void) __attribute__ ((weak, alias("Tone_Handler")));
51+
void TC0_Handler (void) __attribute__ ((weak, alias("Tone_Handler")));
5252
#else
5353
void TC5_Handler (void) __attribute__ ((weak, alias("Tone_Handler")));
5454
#endif
@@ -83,7 +83,7 @@ void tone (uint32_t outputPin, uint32_t frequency, uint32_t duration)
8383
NVIC_SetPriority(TONE_TC_IRQn, 5);
8484

8585
#if defined(__SAMD51__)
86-
GCLK->PCHCTRL[TONE_TC_GCLK_ID].reg = GCLK_PCHCTRL_GEN_GCLK0_Val | (1 << GCLK_PCHCTRL_CHEN_Pos);
86+
GCLK->PCHCTRL[TONE_TC_GCLK_ID].reg = GCLK_PCHCTRL_GEN_GCLK0_Val | (1 << GCLK_PCHCTRL_CHEN_Pos);
8787
#else
8888
// Enable GCLK for TC4 and TC5 (timer counter input clock)
8989
GCLK->CLKCTRL.reg = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(GCM_TC4_TC5));

0 commit comments

Comments
 (0)