Skip to content

Commit 633e48f

Browse files
committed
Servo: use peripheral clock frequency when calculating FRC1 tick count (#1789)
1 parent 3d3c928 commit 633e48f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libraries/Servo/src/esp8266/ServoTimers.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ struct ServoTimer0
126126

127127
#if !defined (SERVO_EXCLUDE_TIMER1)
128128

129+
#define TIMER1_TICKS_PER_US (APB_CLK_FREQ / 1000000L)
130+
129131
struct ServoTimer1
130132
{
131133
public:
@@ -137,11 +139,11 @@ struct ServoTimer1
137139

138140
uint32_t usToTicks(uint32_t us) const
139141
{
140-
return (clockCyclesPerMicrosecond() / 16 * us); // converts microseconds to tick
142+
return (TIMER1_TICKS_PER_US / 16 * us); // converts microseconds to tick
141143
}
142144
uint32_t ticksToUs(uint32_t ticks) const
143145
{
144-
return (ticks / clockCyclesPerMicrosecond() * 16); // converts from ticks back to microseconds
146+
return (ticks / TIMER1_TICKS_PER_US * 16); // converts from ticks back to microseconds
145147
}
146148

147149
void InitInterrupt(timercallback handler)

0 commit comments

Comments
 (0)