Pololu USB AVR User Manual

Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation
Pololu USB AVR Programmer
User's Guide
http://www.pololu.com/docs/0J36/all Page 1 of 54
Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation
1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.a. Module Pinout and Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.b. Supported Microcontrollers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.c. Supported Operating Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2. Contacting Pololu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3. Getting Started in Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.a. Installing Windows Drivers and Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.b. Programming AVRs Using Atmel Studio 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.b.1. Adding Devices to Atmel Studio 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.b.2. Using Advanced Features of Atmel Studio 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.b.3. Faster programming with F5 in Atmel Studio 6 . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.c. Programming AVRs Using AVR Studio 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.c.1. Using Advanced Features of AVR Studio 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.d. Programming AVRs Using AVRDUDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.e. Configuring the Programmer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4. Getting Started in Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.a. Linux Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.b. Programming AVRs in Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
5. Getting Started in Mac OS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.a. Firmware Support for Mac OS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.b. Programming AVRs in Mac OS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
6. Communicating via the USB-to-TTL-Serial Adapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
6.a. Communicating via the Serial Control Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
7. Measuring Voltages Using the SLO-scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
8. Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
9. Upgrading Firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Page 2 of 54
Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation
The Pololu USB AVR programmer [http://www.pololu.com/product/1300] is a programmer for Atmel’s AVR microcontrollers and controller boards based on these MCUs, such as Pololu Orangutan robot controllers
[http://www.pololu.com/category/8/robot-controllers] and the 3pi robot [http://www.pololu.com/product/975]. The programmer
emulates an STK500 on a virtual serial port, making it compatible with standard AVR programming software. Two additional features help with building and debugging projects: a TTL-level serial port for general-purpose communication and a SLO-scope for monitoring signals and voltage levels.
Please note that this guide applies to Pololu’s second-generation AVR programmer (pictured to the left below), not the original, similar-looking Orangutan USB programmer [http://www.pololu.com/product/740] (pictured to the right).
USB AVR programmer PGM03A.
Orangutan USB programmer PGM02A/B.
If you have the original Orangutan USB programmer, you can find it’s user’s guide here [http://www.pololu.com/docs/
0J6].

Important Safety Warning and Handling Procedures

The USB AVR programmer is not intended for young children! Younger users should use this product only under adult supervision. By using this product, you agree not to hold Pololu liable for any injury or damage related to the use or to the performance of this product. This product is not designed for, and should not be used in, applications where the malfunction of the product could cause injury or damage. Please take note of these additional precautions:
• The USB AVR programmer contains lead, so follow appropriate handling procedures, such as washing hands after handling.
• Since the PCB and its components are exposed, take standard precautions to protect your programmer from ESD (electrostatic discharge), such as first touching the surface the programmer is resting on before picking it up. When handing the programmer to another person, first touch their hand with your hand to equalize any charge imbalance between you so that you don’t discharge through the programmer as the exchange is made.
1. Overview Page 3 of 54
Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation

1.a. Module Pinout and Components

Pololu USB AVR programmer, labeled top view.
The Pololu USB AVR programmer connects to a computer’s USB port via an included USB A to mini-B cable
[http://www.pololu.com/product/1129], and it connects to the target device via an included 6-pin ISP programming cable [http://www.pololu.com/product/972] (the older, 10-pin ISP connections are not directly supported, but it is easy to create
or purchase a 6-pin-to-10-pin ISP adapter).
The USB AVR programmer has three indicator LEDs:
• The green LED indicates the USB status of the device. When you connect the programmer to the computer via the USB cable, the green LED will start blinking slowly. The blinking continues until it receives a particular message from the computer indicating that the drivers are installed correctly. After the programmer gets this message, the green LED will be on, but it will flicker briefly when there is USB activity.
• The yellow LED indicates that the programmer is doing something. When it is blinking, it means that the programmer has detected the target device (the voltage on the target VDD line is high). When it is on solid, it means that the SLO-scope is enabled, and lines A and B are used for the SLO-scope instead of the USB-to-TTL­serial adapter.
• The red LED indicates an error or warning. When it is blinking, it means that the target device is not detected (the voltage on the target VDD line is low). When it is on solid, it means that the last attempt at programming resulted in an error. You can determine the source of the error by running the configuration utility (see Section
3.e).
The VBUS line provides direct access to the 5V VBUS line on the USB cable and can be used to power additional devices. The line can provide up to 100 mA, so the current draw of your programmer plus any additional devices should not exceed this amount. If you attempt to draw more than this limit, your computer might disconnect the USB port temporarily or take other actions to limit the use of USB power.
1. Overview Page 4 of 54
Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation
The GND line provides direct access to the grounded line on the USB cable (and ground on the programmer).
The TX and RX lines are the TTL serial port for the USB-to-TTL-serial adapter. They are labeled from the computer’s perspective: TX is an output that connects to your target’s serial receive pin and RX is an input that connects to your target’s serial transmit pin. Section 6 describes how to use these lines to communicate with your devices from the computer.
The A and B lines can be used as serial control/handshaking lines for the USB-to-TTL-serial adapter (see Section
6.a) or as analog voltage inputs for the SLO-scope (see Section 7).
Pololu USB AVR programmer bottom view with
dimensions.
The USB AVR programmer has a standard 6-pin AVR ISP connector for programming AVRs, and the pins are labeled on the silkscreen on the bottom side of the board. The pins on the connector are:
1. MISO: The “Master Input, Slave Output” line for SPI communication with the target AVR. The programmer is the master, so this line is an input.
2. VDD: An input line that the programmer uses to measure the voltage of the target AVR. While programming the target device, the programmer uses this line to constantly monitor the target VDD. If the voltage goes too low or varies too much, then the programmer aborts programming in order to avoid damage to the target AVR. Section 3.e has more information about target VDD monitoring. The VDD line is not used to power the programmer; the programmer is powered from the USB. This line cannot be used to power the target device; the target device must be independently powered for programming to work.
3. SCK: The clock line for SPI communication with the target AVR. The programmer is the master, so this line is an output during programming.
4. MOSI: The “Master Output, Slave Input” line for SPI communication with the target AVR. The programmer is the master, so this line is an output during programming.
5. RST: The target AVR’s reset line. This line is used as an output driven low during programming to hold the AVR in reset.
6. GND: Ground. This line should be connected to the target device’s ground.

1.b. Supported Microcontrollers

The programmer should work with all AVRs that can be programmed with the AVR ISP interface, but it has not been tested on all devices. It has been tested with all Orangutan robot controllers [http://www.pololu.com/category/8/
1. Overview Page 5 of 54
Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation
robot-controllers] and the 3pi Robot [http://www.pololu.com/product/975]. The programmer features upgradable firmware,
allowing updates for future devices. It does not currently work with Atmel’s XMega line of microcontrollers.
The programmer is powered by the 5V USB power bus, and it is intended for programming AVRs that are running at close to 5 V (note that the programmer does not deliver power to the target device).

1.c. Supported Operating Systems

The Pololu USB AVR programmer has been tested under Microsoft Windows XP (Service Pack 3), Windows Vista, Windows 7, Windows 8, and Linux. See Section 5 for limited Mac OS X support.
The programmer’s configuration utility works only in Windows, but this should not be a big problem for Linux users because all the options that can be set in the configuration utility are stored in persistent memory, so you would only have to use Windows when you want to change those parameters, which should be rarely (if ever). The programmer does not require the configuration to program AVRs or to use the TX and RX USB-to-TTL-serial adapter pins.
The SLO-scope application works only in Windows.
The programmer is compatible with a variety of AVR programming utilities for Windows, Linux and Mac OS, including AVRDUDE, AVR Studio 4, AVR Studio 5, and Atmel Studio 6.
1. Overview Page 6 of 54
Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation

2. Contacting Pololu

You can check the Pololu USB AVR programmer page
[http://www.pololu.com/product/1300] for additional information. We would be
delighted to hear from you about any of your projects and about your experience with the Pololu USB AVR Programmer. You can contact us
[http://www.pololu.com/contact] directly or post on our forum [http://forum.pololu.com/]. Tell us what we did well, what we could improve,
what you would like to see in the future, or anything else you would like to say!
2. Contacting Pololu Page 7 of 54
Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation

3. Getting Started in Windows

The Pololu USB AVR programmer works in Windows XP, Windows Vista, and Windows 7.

3.a. Installing Windows Drivers and Software

If you use Windows XP, you will need to have either Service Pack 3 [http://www.microsoft.com/downloads/
details.aspx?FamilyId=68C48DAD-BC34-40BE-8D85-6BB4F56F5110] or Hotfix KB918365 installed before
installing the drivers for the Pololu USB AVR programmer. Some users who installed the hotfix have reported problems using the programmer which were solved by upgrading to Service Pack 3, so we recommend Service Pack 3 over the hotfix.
Please note that these drivers will only work for the USB AVR programmer; if you have Pololu’s original Orangutan
USB programmer [http://www.pololu.com/product/740], you will need to install the drivers specific to that device.
Before you connect your Pololu USB AVR programmer to a computer running Microsoft Windows, you must install its drivers:
1. Download and install the Pololu AVR Development Bundle [http://www.pololu.com/file-redirect/avr-development-
bundle] (~11 MB exe). This includes the drivers and software for the Pololu USB AVR Programmer, along
with the Pololu AVR C/C++ Library and the Orangutan SVP Drivers. If you are not sure which of these components you need, it is OK to install all of them. If you only need to install the drivers and software for the programmer, you can download those separately: USB AVR Programmer Windows Drivers and Software
[http://www.pololu.com/file/download/pololu-usb-avr-programmer-win-121114.exe?file_id=0J486] (11MB exe).
2. During the installation, Windows will ask you if you want to install the drivers. Click “Install” (Windows 8, 7, and Vista) or “Continue Anyway” (Windows XP).
Windows 8, Windows 7, and Windows Vista users: After the installation has finished, your computer should automatically install the necessary drivers when you connect a Pololu USB AVR programmer, in which case no further action from you is required.
Windows XP users: After the installation has finished, follow steps 3-7 for each new Pololu USB AVR programmer you connect to your computer.
3. Getting Started in Windows Page 8 of 54
Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation
3. Connect the USB AVR programmer to your computer’s USB port. The programmer is actually three devices in one so your XP computer will detect all three of those new devices and display the “Found New Hardware Wizard” three times. Each time the “Found New Hardware Wizard” pops up, follow steps 4-7.
4. When the “Found New Hardware Wizard” is displayed, select “No, not this time” and click “Next”.
5. On the second screen of the “Found New Hardware Wizard”, select “Install the software automatically” and click “Next”.
3. Getting Started in Windows Page 9 of 54
Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation
6. Windows XP will warn you again that the driver has not been tested by Microsoft and recommend that you stop the installation. Click “Continue Anyway”.
7. When you have finished the “Found New Hardware Wizard”, click “Finish”. After that, another wizard will pop up. You will see a total of three wizards when plugging in the programmer. Follow steps 4-7 for each wizard.
3. Getting Started in Windows Page 10 of 54
Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation
If you use Windows XP and experience problems installing the serial port drivers, the cause of your problems might be a bug in older versions of Microsoft’s usb-to-serial driver usbser.sys. Versions of this driver prior to version 5.1.2600.2930 will not work with the USB AVR programmer. You can check what version of this driver you have by looking in the “Details” tab of the “Properties” window for C:\Windows\System32\drivers\usbser.sys. To get the fixed version of the driver, you will need to either install Service Pack 3 [http://www.microsoft.com/downloads/
details.aspx?FamilyId=68C48DAD-BC34-40BE-8D85-6BB4F56F5110] or Hotfix KB918365. Some users who installed the
hotfix have reported problems using the programmer which were solved by upgrading to Service Pack 3, so we recommend Service Pack 3 over the hotfix.
After installing the drivers, if you go to your computer’s Device Manager and expand the “Ports (COM & LPT)” list, you should see two COM ports: “Pololu USB AVR Programmer Programming Port” and “Pololu USB AVR Programmer TTL Serial Port”. In parentheses after these names, you will see the name of the port (e.g. “COM3” or “COM4”). If you expand the “Pololu USB Devices” list you should see an entry for the Pololu USB AVR programmer.
3. Getting Started in Windows Page 11 of 54
Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation
Windows XP device manager showing the Pololu USB AVR
Windows 8 device manager showing the Pololu USB AVR Programmer
Programmer
Some software will not allow connection to higher COM port numbers. In particular, AVR Studio and early versions of Atmel Studio cannot connect to ports higher than COM9. If you need to change the COM port number assigned to your programmer, you can do so using the Device Manager. Double-click the COM port to open the properties dialog, and click the “Advanced…” button in the “Port Settings” tab. From this dialog you can change the COM port assigned to the programmer.
Once your have successfully installed the device drivers and software, you can run the Pololu USB AVR Programmer Configuration Utility, which is available in the Start menu in the Pololu folder. This application allows you to change many of the settings of your programmer and can help troubleshoot problems. Please see Section 3.e for more information.
This software package also contains the installation files for the Pololu SLO-scope application for Windows. Please see Section 7 for installation and usage instructions.
3. Getting Started in Windows Page 12 of 54
Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation

3.b. Programming AVRs Using Atmel Studio 6

If you have an Orangutan or 3pi Robot or wish to use the Pololu AVR C/C++ Library for some other reason, we recommend following the Pololu AVR Programming Quick Start Guide
[http://www.pololu.com/docs/0J51] instead of this tutorial.
The following tutorial covers the steps needed to program AVRs in Windows using Atmel Studio 6
[http://www.atmel.com/microsite/atmel_studio6/] and a Pololu USB AVR Programmer. Atmel Studio 6 is a free integrated
development environment (IDE) provided by Atmel. In this tutorial, we will write a simple program to blink an LED connected to pin PD1 of an AVR. If you want to program an AVR that does not have an LED connected to pin PD1, the code in this tutorial can be modified.
You will need to:
• Download and install Atmel Studio 6 [http://www.atmel.com/microsite/atmel_studio6/] by following the instructions on Atmel’s website.
• Install the Pololu USB AVR Programmer’s drivers on your computer. See Section 3.a for instructions.
• Upgrade your programmer’s firmware to version 1.07 or later. See Section 9 for instructions. If your programmer was shipped from Pololu after 2012-02-29, then you already have the right firmware.
• Add the appropriate XML file to Atmel Studio 6 to get it to support the AVR you wish to program, if necessary. See Section 3.b.1 for instructions.
After you have completed these prerequisites, you can create a new Atmel Studio 6 project:
1. Open Atmel Studio 6 and click New Project. In the New Project dialog, select GCC C Executable Project for the template. Enter the project name and location. In this tutorial, we will name our project “BlinkLED” and put it in the “C:\” directory, but you can choose a different name and location if you would like. Uncheck the Create directory for solution box to simplify the directory structure of your project. Click OK.
The New Project dialog of Atmel Studio 6.
3. Getting Started in Windows Page 13 of 54
Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation
2. In the Device Selection window, select the device name of your specific AVR. Click OK to create the project.
The Device Selection dialog of Atmel Studio 6.
3. Remove the template code that was automatically placed in BlinkLED.c and replace it with the code below:
#define F_CPU 20000000 // AVR clock frequency in Hz, used by util/delay.h #include <avr/io.h> #include <util/delay.h>
int main() {
}
DDRD |= (1<<DDD1); // set LED pin PD1 to output while (1) {
PORTD |= (1<<PORTD1); // drive PD1 high _delay_ms(100); // delay 100 ms PORTD &= ~(1<<PORTD1); // drive PD1 low _delay_ms(900); // delay 900 ms
}
Note: The value of F_CPU should be the clock frequency of your AVR in units of Hz, so if your AVR is not running at 20 MHz you will need to change that line. If you do not make this change, the timing of _delay_ms() will be off, but the LED will still blink.
4. Click the Build Solution button on the toolbar (or press F7) to compile the code.
3. Getting Started in Windows Page 14 of 54
Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation
Building a project with Atmel Studio 6.
5. Make sure your USB AVR programmer is connected to your computer via its USB A to mini-B cable and then select Add target… from the Tools menu. Select STK500 as the tool. Select the COM port that has been assigned to the programmer’s programming port, and click Apply. If you are not sure which COM port to select, look in the Device Manager under the “Ports (COM & LPT)” list. This step can be skipped if you have done it before.
3. Getting Started in Windows Page 15 of 54
Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation
The “Add target” dialog box in Atmel Studio 6.1.
6. Click the Device Programming button on the toolbar. You can also select Device Programming from the Tools menu.
7. This will bring up the Device Programming dialog. For the Tool, select the STK500 that you added earlier. Select the same device you selected earlier. If your device is not in the list, you will need to add it to the list by following the instructions in Section 3.b.1. For the Interface, select ISP. Click Apply.
Selecting a programmer, device, and interface in the Device
Programming dialog of Atmel Studio 6.
If you got an error that says “Unable to connect to tool STK500” and you see an error message in the Output pane in the main window that says “The signature of the attached tool is AVRISP_2, which is unexpected.” then you need to upgrade your programmer’s firmware to version 1.07 or later (see Section 9). If you get a different error, see Troubleshooting (Section 8) for help identifying and fixing the problem.
3. Getting Started in Windows Page 16 of 54
Pololu USB AVR Programmer User's Guide © 2001–2014 Pololu Corporation
8. If you have not done so already, connect the programmer to the target device using the 6-pin ISP cable. Make sure the cable is oriented so that pin 1 on the connector lines up with pin 1 on your target device, and that the target device is powered on. You can test the connection by clicking the Read button next to the Device Signature box. This sends a command to the target AVR asking for its signature. If everything works correctly, you should see a number in hex notation appear in the Device Signature box. If you get an error about the signature being wrong, you might have selected the wrong device. If you get a warning that says “Read voltage … is outside selected device’s operating range” then double check to make sure that your device is powered and that you have upgraded the programmer to firmware version 1.07 or later. For more help getting your connection working, see Troubleshooting (Section 8).
Reading the device signature of an AVR in Atmel
Studio 6.
9. Now it is time to program your target device. Select the Memories section on the left. The Flash box should contain the path to the ELF file that was generated when you built your program. If it does not, you can browse for this using the “…” button to the right of the text box. If you navigate to your project’s folder, you should find it as “Debug\<project name>.elf”. Click the Program button in the Flash box.
The Memories section of the Device Programming dialog in Atmel Studio 6.
3. Getting Started in Windows Page 17 of 54
Loading...
+ 37 hidden pages