Commit 9090a5c3a0520ed3f82f9028769d74fed6febccd
authorTibor Peluch <messani@gmail.com>
Thu, 1 Sep 2016 19:43:52 +0000 (21:43 +0200)
committerTibor Peluch <messani@gmail.com>
Thu, 1 Sep 2016 19:43:52 +0000 (21:43 +0200)
simavr/sim/avr_timer.c

index b1de9bd4ff830db90b47086002c9dae27559902d..dba4e9bc0a36b9a60f0f6163b8cd7f439ffa4e77 100644 (file)
@@ -462,7 +462,7 @@ avr_timer_write(
                        // to be synced. To obtain better simulation results
                        // p->tov_base type must be float or avr->frequency
                        // must be multiple of 32768.
-                       p->cs_div_clock = avr->frequency / 32768;
+                       p->cs_div_clock = (uint32_t)((float)avr->frequency * (1 << p->cs_div[new_cs]) / 32768);
                } else {
                        p->cs_div_clock = 1 << p->cs_div[new_cs];
                }