When i have a prototype working well on my breadboard, i sometimes want to make it more robust by putting it on a soldered board, using only the Arduino chip (ATmega328) without the actual Arduino board. This is a lot cheaper. I use a standard ATmega328P-PU chip as used on the Arduino Uno. This can be run with an external 16MHz crystal as described here, but i used the internal 8MHz clock to minimize parts. The first job is to burn a bootloader on this chip. You first need to add a new board definition file to your Arduino IDE.  I put it in my home directory sketchbook/hardware, but my Arduino software did not include the new board (i use Linux), so i added it to my Arduino program files at /home/tom/arduino/arduino-1.0.6/hardware/arduino/

First let’s have a look below at the pins on the ATmega328; in blue the corresponding Arduino pins.

Screenshot 2015-02-21 at 20.27.17

BURN BOOTLOADER

I used a Seeeduino to burn the bootloader, as in below picture (connect power 2xGND, Vcc and AVcc, and 3 SPI pins: 11,12,13 and pin1 to D10 on the board, see here for details).

barebones-burnbootloader

Seeeduino (red board) as ISP for ATmega328 chip

In the Arduino IDE, do as follows:

  • select the actual board (Duemilanove for my Seeeduino)
  • under Tools set programmer to ‘Arduino as ISP’
  • upload the sketch ‘Arduino ISP’

Keeping the same wiring, do:

  • change board to ‘ATmega328 on breadboard’
  • under Tools select ‘Burn bootloader’

Above worked with fresh IC’s, but after experimenting a bit with them, including burning the Optiloader, i was not able to burn the standard bootloader for 8MHz again without adding a 16MHz crystal and 2x 22pF capacitors. After that, i could remove them to upload the sketch.

This works for Atmega328P (e.g. the standard Atmega328P-PU) chips; if you happen to have the Atmega328-PU then you can hack your IDE to be able to burn the bootloader as described here. First figure out which avrdude.conf your IDE is using (see the verbose command in the lower window), for me on Linux with IDE 1.6.5, it was at /home/tom/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino6/etc/ – not the same as described in the above link. I tried this only with the 16MHz setup, for Duemilanove board type.

UPLOAD SKETCH

Once this is successfully done, we’re ready to upload sketches to this ATmega328. You can do this using your Arduino board if you can remove the original ATmega chip, which was not possible with the Seeeduino. But i have an FTDI cable (USB to Serial) which makes this a lot easier.

Connections for FTDI (5 wires):

  • connect GND to 2 GNDs on ATmega
  • connect 5V to Vcc and AVcc on ATmega
  • connect TX to ATmega pin 2 (RX)
  • connect RX to ATmega pin 3 (TX)
  • connect RTS to ATmega pin 1 via a capacitor, type 104 (0.1uF), and pull-up resistor to 5V

It did not work for me without the capacitor. It’s also useful to put an LED on the ATmega pin 19 (Arduino D13) to test with the blink sketch.

barebones-uploadsketch

upload sketch to an ATmega328 by FTDI cable

As soon as this works, it can be soldered on a board for a more permanent setup. I usually include a 5-pin header for jumper wires to the FTDI pins to be able to upload new sketches.

barebones-soldered

example of a ‘bare bones’ Arduino setup, with an ATmega328 and LM386 soldered on a board, powered directly from a 3.7V Lipo battery

For projects that need a 16MHz Arduino setup, i tried the Optiloader sketch which allows to burn bootloaders one chip after the other, with feedback in the Serial Monitor. It burnt the bootloaders (i assume 16MHz as it doesn’t seem to support 8MHz) but i had difficulty uploading sketches using my FTDI cable (USB to Serial). I had the impression that the Optiloader does not handle the Reset signal as well as the standard bootloader: i get the infamous ‘programmer is not responding’ error in the IDE. I had to manually connect RST (pin0) to GND immediately after i hit the upload button; i could not make it work automatically with the RST of the USB cable. When i managed to upload blink, it worked at half the speed even with the 16MHz crystal in place. So i went back to the standard bootloader as above (board type Duemilanove).

IMG_20151223_112523430

Arduino Uno with Optiloader sketch, burning bootloaders on ATmega328P-PU

 

2 thoughts on “Bare bones Arduino internal clock 8MHz

Leave a Reply

Your email address will not be published. Required fields are marked *