Fix for 3.3V instability #626
Replies: 4 comments 7 replies
-
Out of curiosity, how long does it take to dump a N64 game with 8MHz? Does it have a huge impact or is the SD card still the limiting factor? |
Beta Was this translation helpful? Give feedback.
-
When I had stability issues I noticed 2 things:
You could check that and see if it helps. Where did you get your Arduino/which one did you get? I have keyestudio's version. When I started looking into automatic/programmatic voltage switching I originally planned to always run the Arduino at 5V and use logic translators to step down to 3.3V. While I still want to do that it will add at least $10 to the cost and require much more SMD soldering. It also would require a new main PCB. So I decided instead to replace the voltage select switch. If starting in 5V and switching to 3.3V afterward resolves your issue you could use the voltage select module that just got added as it starts the Arduino in 5V mode and switches to 3.3V after boot. |
Beta Was this translation helpful? Give feedback.
-
I think it was just low quality ATmegas that got produced during the global chip shortage. The project is already 8 years old and this is the first time we had widespread issues with 3.3V. The datasheet specifies min. 4.5V, max. 85°C, for 16MHz. We are not running the ATmega that hot, so naturally there is some wiggle room with the voltage as chips get more efficient when running colder. I mean it's not a medical device just a cartridge reader. As for the starting up issue at 3.3V, you probably just need to set the brown-out fuse bit to a lower voltage or just disable it altogether. The automatic voltage switch will fix one related issue though, the power/voltage switches build up a layer of oxidation with time that can be removed again by re-soldering it. You can actually measure it with an multimeter, the resistance gets higher, like from ~0.1Ohm to 1 or 2 Ohm after some time and then gets down to ~0.1Ohm after re-soldering again. Clocking the ATmega at 8MHz is not an option as the dumping times show. I did a mock-up with MCP27S17 extenders and a RPi Pico instead of the ATmega but I didn't like the added complexity, still nice though: |
Beta Was this translation helpful? Give feedback.
-
I added dynamic clock scaling based on the system that was selected in #752 You need to enable it in the config, it's disabled by default. Since most people don't need it, and it makes dumping N64 games painfully slow, I didn't want to enable it by default. The upside of this vs. the proposed solution is that it only clocks down to 8MHz when dumping a 3.3V game. This way, you don't need to dump all games more slowly. Hopefully, that fixes it for the people with issues. If anyone still has issues let me know if it helps :3 |
Beta Was this translation helpful? Give feedback.
-
TLDR: setting the ATMEGA2560 clock frequency to 8MHz appears to fix stability issues in 3.3V mode.
I have built the v3 hardware Cart Reader and programmed it with the v9.5 firmware. It worked fine in 5V mode, but 3.3V mode did not work properly (OLED screen was blank or corrupted, ROM dumps would not complete). The default system clock frequency for the Arduino Mega 2560 is 16MHz and if you check the ATMEGA2560 data sheet section 31.2 (https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ProductDocuments/DataSheets/ATmega640-1280-1281-2560-2561-Datasheet-DS40002211A.pdf) it shows that a Vcc range between 4.5V - 5.5V is "safe" when running with a 16MHz clock. It also shows that a Vcc range between 2.7V - 5.5V is "safe" when running with an 8MHz clock. So I tried using the 8MHz clock, and this seemed to fix my issues in 3.3V mode.
You can set the system clock prescaler so that the cpu clock frequency is 8MHz by adding the following code at the beginning of the "void setup()" function in "Cart_Reader.ino":
noInterrupts();
CLKPR = _BV(CLKPCE); // enable change of the clock prescaler
CLKPR = _BV(CLKPS0); // divide frequency by 2
interrupts();
Now the ATMEGA2560 will run at 8MHz. However, this means that all timing funtionality that counts clocks will take twice as long as before. This can be fixed by setting the f_cpu value for the Arduino Mega 2560 in the "V9.5_Portable/Arduino IDE Portable/hardware/arduino/avr/boards.txt" file to 8000000L instead of its default 16000000L - i.e. change line 211 to
mega.build.f_cpu=8000000L
(Probably a "better" solution would be to define a new board in boards.txt (called somthing like "Cart Reader 2560"), copying all of the Arduino Mega 2560 settings and just changing the f_cpu for that new board definition, and leaving the Arduino Mega 2560 definition alone.)
I have tested the 8MHz clock for dumping Gameboy ROMs in 5V mode and N64 ROMs in 3.3V mode and it seems to work. I have not been able to test any other functionality.
Hopefully this will help anyone that is having stability issues in 3.3V mode.
Beta Was this translation helpful? Give feedback.
All reactions