Posts Tagged ‘168’

Using an Atmel ATmega168 for Arduino on a breadboard

Sunday, January 5th, 2014

For all the people which want to profit from the easy development with Arduino also on custom hardware, here is how to get your hardware running when not completely copying the original Arduino (UNO) schematic.

The Arduino UNO board uses an external 16 MHz oscillator to clock the ATmega328. For a project, I used an ATmega168 with internal RC oscillator, so none of the standard Arduino boards offered in the Arduino IDE suited my configuration.

To be able to talk to the custom board and load the Arduino bootloader, you have to add a custom board to the Arduino IDE:

The available boards in the Arduino IDE are stored in the ./hardware/arduino/boards.txt file of your Arduino directory.

To add an additional board, just add the following code at the bottom of the file:
##############################################################

avr168p.name=Breadboard int clock 8MHz w/ ATmega168

avr168p.upload.using=arduino:arduinoisp
avr168p.upload.maximum_size=16384

avr168p.bootloader.low_fuses=0xe2
avr168p.bootloader.high_fuses=0xdd
avr168p.bootloader.extended_fuses=0x07
avr168p.bootloader.path=arduino:atmega
avr168p.bootloader.file=ATmegaBOOT_168_pro_8MHz.hex
avr168p.bootloader.unlock_bits=0x3F
avr168p.bootloader.lock_bits=0x3F

avr168p.build.mcu=atmega168
avr168p.build.f_cpu=8000000L
avr168p.build.core=arduino:arduino
avr168p.build.variant=arduino:standard
##############################################################

The parameters are pretty self-explaining – this is also the point where you can set the fuses of your controller. To get the fuse values, I recommend to use a fuse value generator like http://www.engbedded.com/fusecalc/