Arduino hardware package for ATmega1284, ATmega644, ATmega324, ATmega324PB, ATmega164, ATmega32, ATmega16 and ATmega8535
Arduino hardware package for ATmega1284, ATmega644, ATmega324, ATmega324PB, ATmega164, ATmega32, ATmega16 and ATmega8535
An Arduino core for ATmega8535, ATmega16, ATmega32, ATmega164, ATmega324, ATmega644 and ATmega1284, all running the Urboot bootloader. Most Arduino UNO-compatible libraries will work with this core. If not, it's fairly straightforward to port a library. MightyCore 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 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.
From MightyCore 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. Other cool features the bootloader provides but are not utilized by MightyCore 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.
If you're looking for a great development board for these DIP-40 microcontrollers, I got you covered! I've used the Arduino UNO for years, but felt like vital functionality was missing on the board. When designing this board I made sure all missing functionality was added. The board can be bought on my Tindie store.
Read more in the hardware section below.
All variants - P, PA, A, PB. Select the correct version in the 'Variant' menu
Can't decide what microcontroller to choose? Have a look at the specification table below:
| mega1284 | mega644 | mega324 | mega164 | mega32 | mega16 | mega8535 | |
|---|---|---|---|---|---|---|---|
| Flash | 128kiB | 64kiB | 32kiB | 16kiB | 32kiB | 16kiB | 8kiB |
| RAM | 16kiB | 4kiB | 2kiB | 1kiB | 2kiB | 1kiB | 0.5kiB |
| EEPROM | 4kiB | 2kiB | 1kiB | 0.5kiB | 0.5kiB | 0.5kiB | 0.5kiB |
| Serial ports | 2 | 2 | 2/3* | 2 | 1 | 1 | 1 |
| PWM pins | 8 | 6 | 6/9* | 6 | 4 | 4 | 4 |
| IO pins | 32 | 32 | 32/39* | 32 | 32 | 32 | 32 |
MightyCore 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, so UART uploads should work fine even though the oscillator is a little too fast or too slow.
| Frequency | Oscillator type | Default upload speed
(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 |
MightyCore lets you select which serial port you want to use for uploading. UART0 is the default port for all targets, but ATmega324/644/1284 can also use UART1 for upload. 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 ATmega8535/16/32/164/324 and 512 bytes on ATmega644/1284.
Note that you need to connect a programmer and hit Burn bootloader if you want to change any of the Bootloader settings.
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 bootloader used in earlier MightyCore versions. The other baud rate options may or may not work, depending on the clock frequency and accuracy of the clock source. A rule of thumb is that "non-round" baud rates like 230400 works best with "non-round" clock speeds like 18.4320 MHz, while "round" ones like 16 MHz work best with "round" baud rates like 250000.
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. To change the BOD settings you'll have to connect an ISP programmer and hit "Burn bootloader". Below is a table that shows the available BOD options:
| ATmega1284 | Atmega644 | ATmega324 | ATmega164 | ATmega32 | ATmega16 | ATmega8535 |
|---|---|---|---|---|---|---|
| 4.3V | 4.3V | 4.3V | 4.3V | 4.0V | 4.0V | 4.0V |
| 2.7V | 2.7V | 2.7V | 2.7V | 2.7V | 2.7V | 2.7V |
| 1.8V | 1.8V | 1.8V | 1.8V | - | - | - |
| Disabled | Disabled | Disabled | Disabled | Disabled | Disabled | Disabled |
If you want the EEPROM to be erased every time you burn the bootloader or upload using a programmer, you can turn off this option. You'll have to connect an ISP programmer and hit "Burn bootloader" to enable or disable EEPROM retain. Note that when uploading using a bootloader, the EEPROM will always be retained.
Note that if you're using an ISP programmer or have the Urboot bootloader installed, data specified in the user program using the EEMEM attribute will be uploaded to EEPROM when you upload your program in Arduino IDE. This feature is not available when using the older Optiboot bootloader.
#include
volatile const char ee_data EEMEM = {"Data that's loaded straight into EEPROM\n"};
void setup() {
}
void loop() {
}Link time optimization (LTO for short) optimizes the code at link time, usually making the code significantly smaller without affecting performance. You don't need to hit "Burn Bootloader" in order to enable or disable LTO. Simply choose your preferred option in the "Tools" menu, and your code is ready for compilation. If you want to read more about LTO and GCC flags in general, head over to the GNU GCC website!
Unlike the official Arduino cores, MightyCore has printf support out of the box. If you're not familiar with printf you should probably read this first. It's added to the Print class and will work with all libraries that inherit Print. Printf is a standard C function that lets you format text much easier than using Arduino's built-in print and println. Note that this implementation of printf will NOT print floats or doubles. This is disabled by default to save space but can be enabled using a build flag if using PlatformIO.
If you're using a serial port, simply use Serial.printf(F("Milliseconds since start: %ld\n"), millis());. As you can see, printf supports the F() macro, but you don't have to us
No open issues yet, or sync has not completed.