From 298bb479b5b0114b3f895285946d14e852a2a866 Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Sun, 26 Jan 2020 10:47:57 -0800 Subject: [PATCH] Explicit cast to prevent integer overflow --- encoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoder.cpp b/encoder.cpp index 9caa45c..7eb57d5 100644 --- a/encoder.cpp +++ b/encoder.cpp @@ -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 }