Programming an ATmega8 with a Bootloader: Part III

USBTinyISP programmer, 16 MHz bootloader, modified board.txt (half speed) and Arduino IDE 1.0.5.

This is one of the 4 methods I will be describing for programming an ATmega8 with a Bootloader. I have split this instructable in four sections so that the reader can directly access its preferred method.

In this section, we will use USBTinyISP programmer, 16 MHz bootloader, modified board.txt (half speed) and Arduino IDE 1.0.5. If you haven’t yet read the introduction this is a good time to do it…Programming an ATmega8 with a Bootloader: Intro.

Optiboot folder already has bootloader for 16 MHz so let’s use it. However, since we are using an 8mhz external crystal we will use the following modifications in board.txt:

  • f_cpu=16000000L
  • speed=57600

Where is boards.txt located?

C:\Program Files (x86)\Arduino\hardware\arduino\avr                                 (If you can’t find it, just use search command…)

boards.txt contains information of all the boards that the IDE shows us when we execute the command Tools->Board.

Open boards.txt with WordPad; each different board definition is separated by a line of “#”.

Copy the following board definition at the end (or wherever you want) separated by lines of “#”.

##############################################################
atmega8_16.name=ATmega8 Optiboot (16MHz external OSC)
atmega8_16.upload.tool=arduino:avrdude
atmega8_16.upload.protocol=arduino
atmega8_16.upload.maximum_size=7680
#57600 for 8MHz xtal; 115200 for 16MHz xtal
atmega8_16.upload.speed=57600
#atmega8_16.bootloader.tool=avrdude
atmega8_16.bootloader.tool=arduino:avrdude
atmega8_16.bootloader.low_fuses=0xbf
atmega8_16.bootloader.high_fuses=0xdc
atmega8_16.bootloader.path=optiboot
atmega8_16.bootloader.file=optiboot_atmega8.hex
atmega8_16.bootloader.unlock_bits=0x3F
atmega8_16.bootloader.lock_bits=0x0F
atmega8_16.build.mcu=atmega8
atmega8_16.build.f_cpu=16000000L
atmega8_16.build.core=arduino
atmega8_16.build.variant=standard
##############################################################

IMPORTANT NOTE: If you want to use a 16 MHz external xtal, just use upload.speed=115200. It’s more precise than the setup that we are using!

This board definition ATmega8 Optiboot (16Mhz external OSC) will let us program ATmega8 with an external crystal of 8MHz (yes….8Mhz since we are using half speed of 57600!)

The next time you start up the Arduino software, you should have a new entry of “ATmega8 Optiboot (16Mhz external OSC)” in the “Boards” menu:
ide_optiboot16
From this point you could burn the bootloader onto the ATmega8 chip by going to Tools menu select Programmer > USBTinyISP and hitting “Burn Bootloader”.

Now, let’s test uploading a sketch using both i) the Arduino UNO and ii) FTDI USB-serial conversion breakboard.

Test using Arduino UNO board:

Once your ATmega8 has the optiboot bootloader on it, you can upload programs using the Arduino UNO board serial communication pins. The UNO board has a USB-to-serial convertor chip (ATmega8U2) built in.

To do, just remove the microcontroller (ATmega328) from the Arduino board so the ATmega8U2 chip (FTDI chip in former board revisions) can talk to the microcontroller on the breadboard instead.

The diagram below shows how to connect the RX and TX lines from the Arduino board to the ATmega8 on the breadboard.

To program the microcontroller, select ” ATmega8 Optiboot (8Mhz external OSC) ” from the Tools > Board menu and upload as usual.

  • Connect Arduino UNO as serial
    • Remove ATmega328 chip
    • Connect Rx, Tx, VCC and GND
  • Tools menu:
    • Serial: Choose your COM port
    • Board: Atmega8 optiboot (8mhz external OSC)
    • Programmer: Arduino as ISP
  • Upload blink sketch!!
    • no need to use upload using programmer, i.e., shift + upload arrow
    • Reset ATmega8: set pin 1 to gnd (you will see three flashes)
    • Press arrow (upload button).

arduino-serial-setup

Test using FTDI chip:

Once the target chip (ATmega8) has the bootloader, just load your code through a normal serial connection. It requires the following:

Use a 0.1uF cap between DTR and the reset pin. From there, all you need are 4 pins to connect to the target circuit – Ground, reset, Tx, Rx. This way you don’t need another Arduino to load code, and the serial monitor will work through the same hardware. Use any Arduino IDE!!

  • Connect FTDI connector as serial
    • DTR to pin 1 via 0.1 uF cap
    • Reset pin1
    • ATmega8 pin2 Rx connect to FTDI Tx
    • ATmega8 pin3 Tx connect to FTDI Rx
  • Tools menu:
    • Serial: Choose your COM port
    • Board: Atmega8 optiboot (16mhz external OSC)
    • Programmer: USBTinyISP
  • Upload blink sketch!!
    • no need to use upload using programmer, i.e., shift + upload arrow
    • Press arrow (upload button).

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: