From 633e48f3aec5f1c3c11d4498fc90d378d49e6e9f Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 24 Mar 2016 01:48:23 +0300 Subject: [PATCH] Servo: use peripheral clock frequency when calculating FRC1 tick count (#1789) --- libraries/Servo/src/esp8266/ServoTimers.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/Servo/src/esp8266/ServoTimers.h b/libraries/Servo/src/esp8266/ServoTimers.h index 1bfac5fb4..90a19e165 100644 --- a/libraries/Servo/src/esp8266/ServoTimers.h +++ b/libraries/Servo/src/esp8266/ServoTimers.h @@ -126,6 +126,8 @@ private: #if !defined (SERVO_EXCLUDE_TIMER1) +#define TIMER1_TICKS_PER_US (APB_CLK_FREQ / 1000000L) + struct ServoTimer1 { public: @@ -137,11 +139,11 @@ public: uint32_t usToTicks(uint32_t us) const { - return (clockCyclesPerMicrosecond() / 16 * us); // converts microseconds to tick + return (TIMER1_TICKS_PER_US / 16 * us); // converts microseconds to tick } uint32_t ticksToUs(uint32_t ticks) const { - return (ticks / clockCyclesPerMicrosecond() * 16); // converts from ticks back to microseconds + return (ticks / TIMER1_TICKS_PER_US * 16); // converts from ticks back to microseconds } void InitInterrupt(timercallback handler)