Alternate CORE files for Arduino

Short version

Sep 29, 2010 Updated to version 0020 core

Based on Version 0020 core files

Download this file (arduino-extras.zip) uncompress it and add it in the hardware folder.
On the Mac, this is /Applications/Arduino.app/Contents/Resources/Java/hardware
This file contains ALL of the defintions that are included in the "arduino" folder as well. So your BOARDS menu will have duplicates.

This will give you access to just about EVERY ATmega that I can find that has been made into a comerically avaialable board.

NOTE: Not all cpus support bootloaders.

Long version

The standard Arduino core files support only a few of the many ATmega microcontrollers. In my opinion, the core files are very well written and very well designed and the Arduino designers are doing a wonderful job of bringing the technology forward.

In order to add a new CPU, the proper way to do it is to duplicate the "arduino" folder in the "hardware" folder and create you own boards.txt, then make the necssary changes to support your particular board. For many boards that use one of the standard CPUs (atmega168, 328, 1280) this is simply a matter of modifing the "pins_arduino.c" file. For other cpus, there are a lot of #ifdefs that need to be modfied.

The problem with this, is when a new version of the Arduino core files come out, those non-standard boards are left in the dust until someone updates the files for THAT board.

The methodoliges for switching CPU type has been done with CPU based #ifdefs. For example

#if defined(__AVR_ATmega1280__)
	...
#endif

#if defined(__AVR_ATmega8__)
	...
#endif

By changing them to register based #ifdefs, then adding a new CPU takes no work at all. For example, in "HardwareSerial.cpp", the buffers for the serial ports were defined as follows:
#if defined(__AVR_ATmega1280__)
	ring_buffer rx_buffer1	=	{ { 0 }, 0, 0 };
	ring_buffer rx_buffer2	=	{ { 0 }, 0, 0 };
	ring_buffer rx_buffer3	=	{ { 0 }, 0, 0 };
#endif
change it to this, where the "UBRR1H" etc. are defined in for the particular CPU that is being used.
#if defined(UBRR1H)
	ring_buffer rx_buffer1	=	{ { 0 }, 0, 0 };
#endif
#if defined(UBRR2H)
	ring_buffer rx_buffer2	=	{ { 0 }, 0, 0 };
#endif
#if defined(UBRR3H)
	ring_buffer rx_buffer3	=	{ { 0 }, 0, 0 };
#endif
This now works for the ATmega168, 328, etc that have ONE serial port. It also works for the Atmega644p that has TWO serial ports AND the 1280/2560 that have FOUR serial ports. All without changing or adding a signle line of code or #ifdefs.

CPUs without UARTS

Some of the ATtiny series CPUs do not have a UART/USART. This can be a real problem. It turns out that the Arduino IDE supports ISP programming. Refer to http://arduino.cc/en/Hacking/Programmer

Even without serial ports and bootloader support, Attinys can be very useful and can be programmed within the Arduino IDE.

At the top of the HardwareSerial.cpp file I have added this line. What it does is DISABLE the entire Serial library if the CPU does not have a UART.

#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
This allows CPUs such as the ATtiny45 to compile properly. Of course, you CANNOT use serial I/O but if you are using that CPU, you already know that.