The AVRISP Programmer

Using the AVRISP Programmer

Introduction

The AVRISP looks just like the JTAGICE, except it's a bit smaller and it has a 6-pin connector on the end of the cable instead of the 10-pin connector on the JTAGICE.

The AVRISP programmer does not have the advanced debugging features of the JTAGICE, but it still allows you to load your program onto the ATmega16. You should try using the AVRISP first, and then if you find that you can't debug your program without stepping through and setting breakpoints, switch to the JTAGICE.

The setup for the AVRISP is different than the JTAGICE, but you can have your breadboard set up with headers to connect both devices so that it's easy to switch between the two.

Connecting the AVRISP to your board

Obtain a 3x2 pin header. I've placed a bunch of these in the supply cabinet with the resistors. Use your pliers to bend the longer set of pins so that the header can be plugged in across one of the gaps in your breadboard.

Bent Header
Figure 1. A bent 3x2 pin header

Plug the header into your breadboard. You probably want to locate it near pin 1 on the ATmega16 to keep your wires short. The following diagram shows the pinout for the ISP (In-System Programming) connector:

Pinout
Figure 2. Pinout for ISP connector

Wire VCC and GND to VCC and GND on your board, and connect MISO, MOSI, SCK, and RESET to the corresponding pins on your ATmega16 (see the AVR datasheet for the pins on the ATmega16). It's okay that you will be sharing some wires with the LEDs you have connected to PORTB. Both the programmer and LEDs will work properly with everything connected at the same time. The result should look something like this:

Wired Header
Figure 3. Completed wiring of ISP header

Plug the 6-pin connector on the end of the AVRISP's cable into the 6-pin header on your board. The red wire indicates the side of the connector with pin 1. Plug the USB cable into your PC, and install the drivers when Windows prompts you. Once the drivers are loaded, the LED on the AVRISP should turn green to indicate that it detects the target voltage on your board.

First-Time Setup

The first time you use the AVRISP with your board, you should follow these setup instructions. For subsequent uses, you can skip ahead to the Programming section.

Open a project in AVR Studio, and click the AVR button in the toolbar to make sure your program is compiled and up-to-date. Select the AVRISP mkII as the platform and USB as the port, then click the Connect button:

Selecting the Programmer
Figure 4. Selecting the Programmer

From the window that appears, select the Main tab. Make sure that the device type is set to ATmega16, and click the Read Signature button. The chip signature for the ATmega16 (0x1E 0x94 0x03) should appear in the window. This verifies that the programmer can communicate with the ATmega16.

Reading Device Signature
Figure 5. Testing the Setup

If reading the signature fails, verify that there is a green light on the AVRISP (if not, it is incorrectly wired to VCC and GND, or your board is not plugged in to power) and that your wiring of the MISO, MOSI, SCK, and RESET lines is correct. If the AVRISP still will not read the device signature, it's possible that ISP programming is disabled in your ATmega16 (we have a few chips still set this way.) You can exchange your ATmega16 for one that's properly programmed with a TA.

Next, check to make sure that the ISP frequency is set to 1.000 MHz. If it is not, click the Settings button, select 1.000 MHz from the menu that appears, and click the Write button.

You're now ready to program your ATmega16 using the AVRISP mkII.

Programming with the AVRISP mkII

To load your program onto your processor, first click the build button in the toolbar (Don't use the "build and run" button, since no debugging platform is connected.) Then, click the AVR button and go to the Program tab. Under the Flash section, make sure the hex file for your project is selected, and then click the Program button.

Programming
Figure 6. Programming the ATmega16

The program will be loaded onto your ATmega16 and should start running automatically, though it never hurts to hit the reset button and make sure that your program starts properly from the beginning.

B. Mayton, January 2009. E-mail cse466-tas@cs with questions.