An Arduino core for the ATmega64 and ATmega128, all running a modified version of Optiboot. Major libraries such as SD, Servo, SPI and Wire are modified to work with this core. Still, a large amount of third-party libraries often works without any modifications.
This core requires at least Arduino IDE v1.6, where v1.6.5+ is recommended.
If you're into "pure" AVR programming, I'm happy to tell you that all relevant keywords are being highlighted by the IDE through a separate keywords file. Make sure to test the example files (File > Examples > AVR C code examples).
- Supported microcontrollers
- Supported clock frequencies
- BOD option
- Programmers
- Why add Arduino support for these microcontrollers?
- Write to own flash
- How to install
- Pinout
- Minimal setup
- ATmega128*
- ATmega64*
(* All variants - A, L and so on)
- They're dirt cheap (can be bought for less than a dollar at AliExpress and Ebay)
- They're still hand solderable (The TQFP variant have 0.8mm pin pitch)
- They're been around for more than a decade, and can be found in a lot of different equipment
- They got 53 IO pins (vs 32 for the MightyCore compatible ones and 86 for the ATmega1280/2560)
##Supported clock frequencies
- 20 MHz external oscillator
- 16 MHz external oscillator (default)
- 12 MHz external oscillator
- 8 MHz external oscillator
- 8 MHz internal oscillator *
- 1 MHz internal oscillator
Select your microcontroller in the boards menu, then select the clock frequency. You'll have to hit "Burn bootloader" in order to set the correct fuses and upload the correct bootloader.
Make sure you connect an ISP programmer, and select the correct one in the "Programmers" menu. For time critical operations an external oscillator is recommended.
* There might be some issues related to the internal oscillator. It's factory calibrated, but may be a little "off" depending on the calibration, ambient temperature and operating voltage. If uploading failes while using the 8 MHz internal oscillator you have three options:
- Edit the baudrate line in the boards.txt file, and choose either 115200, 57600, 38400 or 19200 baud.
- Upload the code using a programmer (USBasp, USBtinyISP etc.) or skip the bootloader
- Use the 1 MHz option instead
##BOD option Brown out detection, or BOD for short lets the microcontroller sense the input voltage and shut down if the voltage goes below the brown out setting. The ATmega64/128 haven't dedicated the BOD selection to extended fuse, so there's no way to only change the BOD option in the Arduino IDE. If you need to change this setting you'll have to edit the boards.txt file.
##Programmers MegaCore does not adds its own copies of all the standard programmers to the "Programmer" menu. Just select one of the stock programmers in the "Programmers" menu, and you're ready to "Burn Bootloader" or "Upload Using Programmer".
Select your microcontroller in the boards menu, then select the clock frequency. You'll have to hit "Burn bootloader" in order to set the correct fuses and upload the correct bootloader.
Make sure you connect an ISP programmer, and select the correct one in the "Programmers" menu. For time critical operations an external oscillator is recommended.
##Write to own flash
A while ago @majekw announced that he'd successfully modified the Optiboot bootloader to let the running program permanently store content in the flash memory.
The flash memory is much faster than the EEPROM, and can handle about 10 000 write cycles.
With help from majek this feature is working perfectly with the MegaCore! To enable this feature the bootloader needs to be replaced by the new one. Simply hit "Burn Bootloader", and it's done!
Please check out the Optiboot flasher example for more info about how this feature works, and how you can try it on your MegaCore compatible microcontroller.
##How to install
This installation method requires Arduino IDE version 1.6.4 or greater.
- Open the Arduino IDE.
- Open the File > Preferences menu item.
- Enter the following URL in Additional Boards Manager URLs:
https://mcudude.github.io/MegaCore/package_MCUdude_MegaCore_index.json
- Open the Tools > Board > Boards Manager... menu item.
- Wait for the platform indexes to finish downloading.
- Scroll down until you see the MegaCore entry and click on it.
- Note: If you are using Arduino IDE 1.6.6 then you may need to close Boards Manager and then reopen it before the MegaCore entry will appear.
- Click Install.
- After installation is complete close the Boards Manager window.
Click on the "Download ZIP" button in the upper right corner. Exctract the ZIP file, and move the extracted folder to the location "~/Documents/Arduino/hardware". Create the "hardware" folder if it doesn't exist. Open Arduino IDE, and a new category in the boards menu called "MegaCore" will show up.
MegaCore works perfectly with Eclipse using the Arduino Eclipse plugin (formally Sloeber). If you're tired of Arduino IDEs limits but still want to stick with open source software; this is the way to go!
- Download and install the latest version of Arduino Eclipse (Download the nighty build if you want support for aditional programmers)
- Open Preferences (Windows: Window -> Preferences, Mac: [App name] -> Preferences)
- Click the expand arrow next to the Arduino option in the preferences menu
- Click Locations, paste the board manager URL and hit the Apply button:
https://mcudude.github.io/MegaCore/package_MCUdude_MegaCore_index.json
- Click the Platform and Boards menu option to the left and expand the MegaCore option. Select the latest version.
- Click the OK button. MiniCore is now installed!
Make sure to select the MegaCore boards.txt file when you create a new sketch.
##Pinout
Since there are no standarized Arduino pinout for the ATmega64/128, I decided to create my own. I've tried to make it as simple and logical as possible. This pinout makes great sense if you're buying this cheap breakout boards at Ebay or AliExpress (just make sure to remove C3 in order to get auto reset working). The standard LED pin is assigned to Arduino pin 13 (PB5), and will blink twice if you hit the reset button.
Click to enlarge:
##Minimal setup
Here is a simple schematic showing a minimal setup using an external crystal. Skip the crystal and the two 22pF capacitors if you're using the internal oscillator.