wokwi / avr8js

Arduino (8-bit AVR) simulator, written in JavaScript and runs in the browser / Node.js
https://blog.wokwi.com/avr8js-simulate-arduino-in-javascript/
MIT License
462 stars 73 forks source link

Timer Overflow (TOV) flag does not update correctly #75

Closed urish closed 3 years ago

urish commented 3 years ago

According to the datasheet, the TOV flag is set depending on the active Waveform Generation Mode. It can be set either when the timer reaches the TOP value, the MAX value, or the BOTTOM value (for example, see Table 15-5).

Currently, we only update it when we reach the TOP value, which is the the correct behavior in some cases (e.g. CTC mode).