Skip to content

Commit

Permalink
Servo: use peripheral clock frequency when calculating FRC1 tick count (
Browse files Browse the repository at this point in the history
  • Loading branch information
igrr committed Mar 23, 2016
1 parent 3d3c928 commit 633e48f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libraries/Servo/src/esp8266/ServoTimers.h
Expand Up @@ -126,6 +126,8 @@ struct ServoTimer0

#if !defined (SERVO_EXCLUDE_TIMER1)

#define TIMER1_TICKS_PER_US (APB_CLK_FREQ / 1000000L)

struct ServoTimer1
{
public:
Expand All @@ -137,11 +139,11 @@ struct ServoTimer1

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)
Expand Down

0 comments on commit 633e48f

Please sign in to comment.