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
481 stars 78 forks source link

delay() is inaccurate (regression) #81

Closed urish closed 3 years ago

urish commented 3 years ago

Reproduction:

void setup() {
  Serial.begin(115200);
  int start = millis();
  delay(500);
  Serial.println(millis() - start);
}

void loop() {
}

With the current AVR8js version, the above code prints 4, while on silicone (and also in previous AVR8js versions) it prints 499.

This issue started happening since 0.14.7 release, which fixed #80.

It can be easily reproduced by going to the AVR8js Serial example, pasting the code above, installing version 0.14.7 of the avr8js package, and running the simulation.