Return to previous page.
There are several issues involved with getting the Arduino environment to work with ATmega1284 and 1284P chips, including:
This page has been compiled after many months of work with ATmega1284 and 1284P chips, and many hours spent on the Arduino Forum troubleshooting these problems, in conjunction with other forum members.
1. Lack of 1284(P) Support in Arduino Libraries
For some reason, Arduino central command didn't include support for ATmega1284(P) chips in the libraries that come packaged with the Arduino IDE. These libraries can be seen by opening the IDE "File > Examples" menu, and include: EEPROM, Ethernet, LiquidCrystal, SD, Servo, on and on.
The fix for this problem is "relatively" simple, because the 1284 and 1284P chips have a similar port assignment to the ATmega2560 and 1280 chips. So, the procedure is:
So, anytime one of the Arduino IDE libraries is used, or a 3rd party library is installed for use with the 1284(P) chips, all of the .cpp and .h source files in the library should be immediately examined to see whether they need the change described here.
Also, see item 10. Misc IDE Files and Libraries Checked for ATmega1284(P) Support, below.
2. 1284(P) Bootloaders
The most commonly used bootloader for 1284(P) is maniacbug optiboot with 16 Mhz crystal, having file name "optiboot_atmega1284p.hex". The same library also contains the older bootloader files "ATmegaBOOT_1284P.hex" and "ATmegaBOOT_1284P_8MHz.hex", which include firmware for both 16 and 8 Mhz operation.
Other bootloaders for 1284(P) chips can also be found on the internet, including for 20 Mhz operation, as well as firmware for ATmega644 and Reprap devices, but they're not considered here.
3. Board Variants
In the maniacbug library, there are several different board variants which use the exact same bootloader firmware, and have names like "Mighty 1284p 16MHz using Optiboot", "avr-developers.com pinouts 16MHz using Optiboot", and "Bobuino", and all three of which use optibootloader file "optiboot_atmega1284p.hex".
The difference between these board variants relates to how the port pins (eg PB0..PB7, PC0..PC7, &etc) of the chip map into different Arduino "functional pin numbers" (ie D0..D13 and A0..A7), and this info is not burned into the chip with the bootloader. Rather, this remapping is taken care of by selecting a particular board in the IDE "Tools > Board" menu when sketches are compiled, and then the appropriate "pins_arduino.h" (pin remapping) file is used.
A typical entry in the boards.txt file in the maniacbug library directory is as follows. It has info on: "name" of the board variant, protocol for "uploading" sketches using the avrdude utility, which "bootloader" is used by the particular board variant, and finally, information used when compiling ("building") sketches for the variant.
The variant shown uses the "optiboot" bootloader running at 16 Mhz on the ATmega1284P chip, and a so-called "standard" pin remapping, as detailed by the "pins_arduino.h" file in the variant's file directory. Notice also, that the processor fuse settings are specified here, and not in the bootloader file itself, and these are the values burned into the chip when the bootloader firmware is burned. To change any of the fuse settings involves re-burning the bootloader into the chip.
Typically, the same board variant will be selected when uploading sketches as was used when the bootloader was burned into the chip.
See the section below on errors in the Bobuino variant files of the maniacbug 1284P library. This variant was added after-the-fact by maniacbug, and has several errors that have not been fixed as of June 2013.
4. 1284 Library Installation
Although some people mistakenly install 3rd party libraries in the main Arudino IDE directory, the proper place is actually in the Arduino sketch directory. This way, new versions of the IDE will always be able to immediately find the 3rd party libraries. See Installing Additional Arduino Libraries page for exact details. Your Arduino sketch directory should end up with a subdirectory as follows:
5. ATmega1284 Chip vs 1284P
The maniacbug library was written specifically for the ATmega1284P chip. However, the same bootloaders also work for the 1284 (non-P) chip, but we found that we needed to follow the following steps to use the 1284 chip with the maniacbug library and the Arduino environment:
This scheme allows the 1284 chip to be used interchangeably with the 1284P with any of the maniacbug board variants, simply be selecting the variant in the IDE "Tools > Board" menu when sketches are compiled and uploaded.
6. RX0 and Sketch Uploading Problems - History
In the past, many [but not all] people had problems uploading sketches to ATmega1284P bootloader chips in DIP40 package. By default, this process uses hardware UART0, ie the RX0,TX0 pins.
It was common to have communications failures during sketch uploading, and several people referenced an avrfreaks forum thread on how to fix this. This fix involved using an RC low-pass between the FTDI USB-to-RS232 chip and the RX0 pin, with typical values of 1K-10K and 100pF.
Although this solved the comms-sync problem, several people investigated further, and came to the conclusion that the problem was actually related to the fact that the XTAL1 (oscillator input) pin is adjacent to RX0 on the DIP40 version of these chips, and the XTAL1 input was being affected by cross-talk. After some brilliant simulations by Pito, plus further investigations, it was generally decided that the "proper" fix was to change the bootloader Low-Fuse setting from low-power oscillator to full-swing oscillator, thus minimizing the effects of said cross-talk.
Ref section 9.2 Clock Sources, in the ATmega1284(P) datasheet .... to do this, one needs to change the following line in the boards.txt file located in the maniacbug 1284P library files.
Note, as mentioned above, this change has not been incorporated into the original maniac1284 library, as of June 2013.
7. 1284 Fuse Settings
Related to the previous section, when trying to sort out the jumble of fuse settings for the 1284 or other chips, it helps to jump directly to "Section 27.2 Fuse Bits" of the ATmega1284 datasheet first, and then go back to individual sections, such as "Section 9.2 Clock Sources".
8. Arduino Forum 1284 Threads
For reference, there have been several long threads on the Arduino Forum dealing with these problem. See,
There are also related threads on the avrfreaks forum.
9. Bobuino Variant Library Errors
There are several errors in the "pins_arduino.h" file for the Bobuino board variant of the maniacbug library, but as of June 2013, these had not been fixed. This file is located in the maniacbug library in the "\variants\bobuino" subdirectory. The following information was posted to github in February 2013, see Issue #4.
The first error causes the A/D channel values, 0..7, to be assigned to the wrong pins. The second error is related to some change which wasn't uniformly made throughout every file used when the IDE was upgraded from the older versions 0022, and earlier, to the newer 1.0.x versions. The last two errors are simple inconsistensies between assignments located in different file locations.
10. Misc IDE Files and Libraries Checked for ATmega1284(P) Support
The following files in Arduino IDE version 1.0.5 have been checked for ATmega1284(P) support. There may also be some support in earlier versions of the IDE, but those are not dealt with here. These files are in the ArduinoCore ".\hardware\arduino\cores\arduino" subdirectory in the Arduino IDE.
NOTE - the "Arduino.h" file in newer versions of the IDE have support for several different ATmega1284(P)and ATmega644(P) chips, as indicated above, in regards Fix #1.
Also, the very end of "Arduino.h" has a < #include "pins_arduino.h" > statement, so it will automatically handle different board variants with different pinouts.
We also checked the following standard Arduino libraries, found in IDE subdirectory "\libraries" :
We've also checked the following 3rd party libraries for ATmega1284P support:
11. Miscellaneous Issues