From 77cca8f6eeaaa03f10486c827ce90312ca310749 Mon Sep 17 00:00:00 2001 From: pmantoine Date: Wed, 17 Aug 2022 14:29:02 +0800 Subject: [PATCH] STM32 switch to Timer11 for DCC interrupts --- DCCTimerSTM32.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/DCCTimerSTM32.cpp b/DCCTimerSTM32.cpp index d055d59..640599f 100644 --- a/DCCTimerSTM32.cpp +++ b/DCCTimerSTM32.cpp @@ -37,22 +37,25 @@ HardwareSerial Serial1(PA10, PA15); // Rx=PA10, Tx=PA15 INTERRUPT_CALLBACK interruptHandler=0; // Let's use STM32's timer #1 until disabused of this notion -HardwareTimer timer(TIM1); +HardwareTimer timer(TIM11); // Timer IRQ handler -void Timer1_Handler() { +void Timer11_Handler() { interruptHandler(); } + + void DCCTimer::begin(INTERRUPT_CALLBACK callback) { interruptHandler=callback; noInterrupts(); + // adc_set_sample_rate(ADC_SAMPLETIME_480CYCLES); timer.pause(); timer.setPrescaleFactor(1); // timer.setOverflow(CLOCK_CYCLES * 2); timer.setOverflow(DCC_SIGNAL_TIME, MICROSEC_FORMAT); - timer.attachInterrupt(Timer1_Handler); + timer.attachInterrupt(Timer11_Handler); timer.refresh(); timer.resume();