From: Konstantin Begun Date: Thu, 23 Feb 2017 01:02:06 +0000 (+0000) Subject: Set prescaler divisor (cs_div_value) to zero when prescaler is reset, i.e. timer... X-Git-Tag: v1.6~47^2 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=4ca2d1ac5b2b74a4e68274fba8b03005d22e9d8f;p=sx%2Fsimavr.git Set prescaler divisor (cs_div_value) to zero when prescaler is reset, i.e. timer is stopped. Otherwise when OCR is set, the tomer gets reconfigured with the old prescaler --- diff --git a/simavr/sim/avr_timer.c b/simavr/sim/avr_timer.c index a1c2b4f..81131a1 100644 --- a/simavr/sim/avr_timer.c +++ b/simavr/sim/avr_timer.c @@ -662,6 +662,7 @@ avr_timer_write( if (new_cs != cs || new_mode != mode || new_as2 != as2) { /* cs */ if (new_cs == 0) { + p->cs_div_value = 0; // reset prescaler // cancel everything avr_timer_cancel_all_cycle_timers(avr, p, 1);