MegaCore
Arduino hardware package for ATmega64, ATmega128, ATmega165, ATmega169, ATmega325, ATmega329, ATmega640, ATmega645, ATmega649, ATmega1280, ATmega1281, ATmega2560, ATmega2561, ATmega3250, ATmega3290, ATmega6450, ATmega6490, AT90CAN32, AT90CAN64 and AT90CAN128
Install / Use
/learn @MCUdude/MegaCoreREADME
MegaCore
An Arduino core for most 64 and 100-pin AVRs, all running the Urboot bootloader.
From version 3.1.0 onwards, debugging in the Arduino IDE 2 is supported. You can use any of Microchip's EDBG-based hardware debuggers. For documentation, see https://pyavrocd.io. MegaCore works with flawless with Arduino IDE 1.8.x, but if you want to debug using a hardware debugger, you'll need Arduino IDE 2.x.
From MegaCore version 3 and onwards, the Optiboot bootloader has been replaced by the superior Urboot bootloader. It's smaller, faster, and has automatic baud rate detection, and can read and write to EEPROM. Other cool features the bootloader provides but are not utilized by MegaCore are user program metadata stored in flash (that can easily be viewed by Avrdude -xshowall) and chip-erase functionality. If you already have Optiboot installed and don't want to replace it with Urboot, you can still upload programs without any compatibility issues. However, if you're burning a bootloader to a new chip, Urboot is the way to go.
Table of contents
- Supported microcontrollers
- Supported clock frequencies
- Bootloader option
- Baud rate option
- BOD option
- EEPROM retain option
- Link time optimization / LTO
- Printf support
- Pin macros
- Write to own flash
- PROGMEM with flash sizes greater than 64kB
- Programmers
- How to install
- Getting started with MegaCore
- Wiring reference
- Pinout
- Minimal setup
Supported microcontrollers:
- ATmega6490
- ATmega6450
- ATmega3290
- ATmega3250
- ATmega2561
- ATmega2560
- ATmega1281
- ATmega1280
- ATmega649
- ATmega645
- ATmega640
- ATmega329
- ATmega325
- ATmega169
- ATmega165
- ATmega128
- ATmega64
- AT90CAN128
- AT90CAN64
- AT90CAN32
(All variants - A, L, P, PA, PV, V) <br/> <br/> Can't decide what microcontroller to choose? Have a look at the specification table below:
| | Mega2560 | Mega1280 | Mega640 | Mega2561 | Mega1281 | Mega128<br/>CAN128 | Mega6490<br/>Mega6450 | Mega64<br/>CAN64<br>Mega649<br/>Mega645 | Mega6490<br/>Mega6450 | CAN32<br/>Mega329<br/>Mega325 | Mega169<br/>Mega165 | |------------------|----------|----------|---------|----------|----------|--------------------|-----------------------|-----------------------------------------|-----------------------|-------------------------------|---------------------| | Flash | 256kB | 128kB | 64kB | 256kB | 128kB | 128kB | 64kB | 64kB | 32kB | 32kB | 16kB | | RAM | 8kB | 8kB | 8kB | 8kB | 8kB | 4kB | 4kB | 4kB | 2kB | 2kB | 1 kB | | EEPROM | 4kB | 4kB | 4kB | 4kB | 4kB | 4kB | 2kB | 2kB | 1kB | 1kB | 512B | | IO pins | 70/86 * | 70/86 * | 70/86 * | 54 | 54 | 53 | 68 | 53 | 68 | 53 | 53 | | Serial ports | 4 | 4 | 4 | 2 | 2 | 2 | 1 | 2 / 1 ** | 1 | 2 / 1 ** | 1 | | PWM pins | 15 | 15 | 15 | 8 | 8 | 7 | 4 | 7 / 4 ** | 4 | 7 / 4 ** | 4 | | LED pin | PB7 | PB7 | PB7 | PB5 | PB5 | PB5 | PB7 | PB5 | PB7 | PB5 | PB5 |
<b>*</b> Pin 70-85 is not broken out on the Arduino Mega. Make sure to check out the AVR style pinout for a more straightforward pinout.
<b>**</b> ATmega165/169/325/329/645/649 has one hardware serial port and four PWM outputs.
Supported clock frequencies
MegaCore supports a variety of different clock frequencies. Select the microcontroller in the boards menu, then select the clock frequency. You will have to hit "Burn bootloader" in order to set the correct fuses and upload the correct bootloader. This also has to be done if you want to change any of the fuse settings (BOD and EEPROM settings) regardless if a bootloader is installed or not.
Make sure you connect an ISP programmer, and select the correct one in the "Programmers" menu. For time-critical operations, an external crystal/oscillator is recommended. The Urboot bootloader has automatic baud rate detection (except when using UART2 and UART3 on ATmega640/1280/2560), so UART uploads should work fine even though the oscillator is a little too fast or too slow.
| Frequency | Oscillator type | Default upload speed <br/>(bootloader has auto-baud) | Comment | |-------------|-----------------------------|-------------------------------------------------------|---------------------------------------------------| | 16 MHz | External crystal/oscillator | 115200 | Default clock on most AVR based Arduino boards | | 20 MHz | External crystal/oscillator | 115200 | | | 18.4320 MHz | External crystal/oscillator | 115200 | Great clock for UART communication with no error | | 14.7456 MHz | External crystal/oscillator | 115200 | Great clock for UART communication with no error | | 12 MHz | External crystal/oscillator | 57600 | | | 11.0592 MHz | External crystal/oscillator | 115200 | Great clock for UART communication with no error | | 9.216 MHz | External crystal/oscillator | 115200 | Great clock for UART communication with no error | | 8 MHz | External crystal/oscillator | 57600 | Common clock when working with 3.3V | | 7.3728 MHz | External crystal/oscillator | 115200 | Great clock for UART communication with no error | | 6 MHz | External crystal/oscillator | 57600 | | | 4 MHz | External crystal/oscillator | 9600 | | | 3.6864 MHz | External crystal/oscillator | 115200 | Great clock for UART communication with no error | | 2 MHz | External crystal/oscillator | 9600 | | | 1.8432 MHz | External crystal/oscillator | 115200 | Great clock for UART communication with no error | | 1 MHz | External crystal/oscillator | 9600 | | | 8 MHz | Internal oscillator | 38400 | Might cause UART upload issues. See comment above | | 4 MHz | Internal oscillator | 9600 | Derived from the 8 MHz internal oscillator | | 2 MHz | Internal oscillator | 9600 | Derived from the 8 MHz internal oscillator | | 1 MHz | Internal oscillator | 9600 | Derived from the 8 MHz internal oscillator |
Bootloader option
MegaCore lets you select which serial port you want to use for uploading. UART0 is the default port for all targets, but any hardware serial port may be used. If your application doesn't need or require a bootloader for uploading you can also choose to disable it by selecting No bootloader. This frees 384 bytes of flash memory on ATmega165/169/325/3250/329/3290 and 512 bytes on ATmega64/128/645/6450/649/6490/1281/2560 and AT90CAN32/64/128.
Note that you need to connect a programmer and hit Burn bootloader if you want to change any of the Bootloader settings.
Baud rate option
Since Urboot has automatic baud rate detection, the upload baud rate can be changed without having to re-flash the bootloader. The default baud rate setting will pick a suited baud rate that also works with the legacy Optiboot bootloa
Related Skills
node-connect
347.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
