Skip to content

Commit

Permalink
Off-by-one in timer setPeriod() function
Browse files Browse the repository at this point in the history
Thanks CarlO!
  • Loading branch information
bnewbold committed Sep 3, 2010
1 parent 3b2cca3 commit 1c6f9a9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions wirish/HardwareTimer.cpp
Expand Up @@ -77,8 +77,8 @@ uint16 HardwareTimer::setPeriod(uint32 microseconds) {
// With a prescale factor of 1, there are 72counts/ms
uint16 ps = ((microseconds*72)/65536) + 1;
setPrescaleFactor(ps);
// Find this overflow will always be less than 65536
setOverflow((microseconds*72)/ps);
// Finally, this overflow will always be less than 65536
setOverflow(((microseconds*72)/ps) - 1);
return this->overflow;
}
void HardwareTimer::setChannel1Mode(uint8 mode) {
Expand Down

0 comments on commit 1c6f9a9

Please sign in to comment.