mirror of
https://github.com/quorten/macsehw.git
synced 2024-05-29 05:41:34 +00:00
Timer accuracy improvement: +=
instead of =
.
This commit is contained in:
parent
c36265d2da
commit
3858671656
|
@ -334,11 +334,13 @@ void oflowInterrupt(void)
|
||||||
{
|
{
|
||||||
numOflows++;
|
numOflows++;
|
||||||
if (numOflows == LIM_OFLOWS) {
|
if (numOflows == LIM_OFLOWS) {
|
||||||
// Configure a timer interrupt to handle the final remainder cycle
|
/* Configure a timer interrupt to handle the final remainder cycle
|
||||||
// wait. We simply subtract the value from 256, which is the same
|
wait. We simply subtract the value from 256, which is the same
|
||||||
// as going negative two's complement and using 8-bit wrap-around.
|
as going negative two's complement and using 8-bit wrap-around.
|
||||||
|
Also, since the timer may have ticked a few cycles since
|
||||||
|
wrap-around, accumulate via `+=`. */
|
||||||
fracRemain += NUMER_FRAC_REMAIN;
|
fracRemain += NUMER_FRAC_REMAIN;
|
||||||
TCNT0 = (fracRemain >= DENOM_FRAC_REMAIN) ?
|
TCNT0 += (fracRemain >= DENOM_FRAC_REMAIN) ?
|
||||||
-(LIM_REMAIN + 1) : -LIM_REMAIN;
|
-(LIM_REMAIN + 1) : -LIM_REMAIN;
|
||||||
fracRemain &= MASK_FRAC_REMAIN;
|
fracRemain &= MASK_FRAC_REMAIN;
|
||||||
} else if (numOflows == LIM_OFLOWS + 1) {
|
} else if (numOflows == LIM_OFLOWS + 1) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user