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
463 stars 73 forks source link

Arduino Mega 2560 #46

Closed elliottkember closed 4 years ago

elliottkember commented 4 years ago

Would love to see an Arduino Mega 2560 version! I hit the Uno memory limits pretty quickly using FastLED, so the extra memory would be super helpful.

urish commented 4 years ago

Example for Arduino Mega 2560 + FastLED simulation:

https://stackblitz.com/edit/avr8js-mega-ws2812?file=execute.ts

In particular, the following changes are required when initializing the simulation:

this.cpu = new CPU(this.program, 0x2200);
this.timer = new AVRTimer(this.cpu, {
  ...timer0Config,
  compAInterrupt: 0x02a,
  compBInterrupt: 0x02c,
  ovfInterrupt: 0x02e,
});

In order to run generic Arduino Mega 2560 simulation, some more changes are needed. For instance, the Mega has 6 timers while the Uno only has 3 timers, more GPIO ports, etc.