Monthly Archives: January 2014

Arduino using ATmega328p with internal 8MHz Crystal with Bus Pirate

I am working in a robotics project where keeping the cost low is crucial. So in order to reduce costs and make the robot easy to program and connect to various types of sensors easily, I choose to use an ATmega328p so I can use the Arduino enviroment but using the internal 8MHz clock.

Here are the steps I made to program the bootloader into the ATmega328p chip using the all-mighty Bus Pirate froam Dangerous Prototypes:

Connect the BP to the microcontroller according to this (add link) table.

in a terminal check the connection between the BP and the microcontroller using

avrdude -c buspirate -p m328p -v -P /dev/ttyUSB0

unlock bootloader section on the chip using

avrdude -c buspirate -p m328p -P /dev/ttyUSB0 -U lock:w:0x3f:m

go to the folder where you installed arduino with

$cd /whatever/arduino/hardware/arduino/bootloaders/atmega

and use this command to write the correct bootloader to the chip

avrdude -c buspirate -p m328p -P /dev/ttyUSB0 -U efuse:w:0x05:m -U hfuse:w:0xDA:m -U lfuse:w:0xE2:m -U flash:w:ATmegaBOOT_168_atmega328_pro_8MHz.hex

then lock again the bootloader section with

avrdude -c buspirate -p m328p -P /dev/ttyUSB0 -Ulock:w:0x0F:m

now test with a ftdi chip to program with the arduino IDE