From be4235e792f365068c69a08e83efc8b598cd0368 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Wed, 24 May 2023 13:29:20 +0200 Subject: [PATCH] Arduino Mega2560: Use timer5 as timer4 for PWM DC --- MotorDriver.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/MotorDriver.cpp b/MotorDriver.cpp index c27f777..8934969 100644 --- a/MotorDriver.cpp +++ b/MotorDriver.cpp @@ -289,6 +289,7 @@ void MotorDriver::setDCSignal(byte speedcode) { #if defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560) TCCR2B = (TCCR2B & B11111000) | B00000110; // set divisor on timer 2 to result in (approx) 122.55Hz TCCR4B = (TCCR4B & B11111000) | B00000100; // same for timer 4 but maxcount and thus divisor differs + TCCR5B = (TCCR5B & B11111000) | B00000100; // same for timer 5 which is like timer 4 #endif // spedcoode is a dcc speed & direction byte tSpeed=speedcode & 0x7F; // DCC Speed with 0,1 stop and speed steps 2 to 127