Explicit cast to prevent integer overflow

This commit is contained in:
Reed Nightingale 2020-01-26 10:47:57 -08:00
parent 1505936713
commit 298bb479b5
1 changed files with 1 additions and 1 deletions

View File

@ -83,7 +83,7 @@ void enc_setup(void)
TCCR1A = 0;//"normal" mode
TCCR1B = 3;//clock divider of 64
TCNT1 = 0;//start counting at 0
OCR1A = F_CPU * CALLBACK_PERIOD_MS / 1000 / 64;//set target number
OCR1A = F_CPU * (unsigned long)CALLBACK_PERIOD_MS / 1000 / 64;//set target number
TIMSK1 |= (1 << OCIE1A);//enable interrupt
}