Next:
5.b.
AVR Studio in More Detail
Previous:
5.
Getting Started Using Windows
Note: The instructions in this section were written for AVR Studio version 4.13, build 528. The most recent version of AVR Studio at the time of this update is version 4.13 Service Pack 2, build 571. The AVRISP dialog has changed slightly in this newer version, so the screen shots you see in this section may differ from what you see when you run AVR Studio.
Here we will show you step by step how to use AVR Studio make the red user LED blink on your Orangutan, Orangutan LV-168, Baby Orangutan, or 3pi robot. If you want to skip the steps that setup the LED-blinker code and jump straight into using your Orangutan USB programmer, you can download the AVR Studio project these steps would help you create—BlinkLED.zip (14k zip)—and proceed straight to step 4. Please note that this BlinkLED program will not work on the Orangutan X2.
- Open AVR Studio and click New Project. Select AVR GCC for the project type. We called our project “BlinkLED” and elected to have a folder called “C:\BlinkLED” created containing the blank file “BlinkLED.c”. Click Next >>. DO NOT click “Finish” yet. If you do accidentally click “Finish”, you will not be able to perform step 2 and will instead have to set the device by going to the Project menu and selecting “Configuration Options”.
 | | Creating a new AVR Studio project, step 1 |
|---|
- Select AVR Simulator as the debug platform and then select the appropriate device for your Orangutan or 3pi. This will be ATmega168 unless you have a mega48 version of the Baby Orangutan, in which case it will be ATmega48. Click Finish.
 | | Creating a new AVR Studio project, step 2 |
|---|
- Write your program in BlinkLED.c as seen in the screen shot below and click the Build button on the toolbar (or press F7), or just download the zipped BlinkLED project archive: BlinkLED.zip (14k zip).
 | | Building a project with AVR Studio |
|---|
Note: You will probably want to customize this program slightly if you are working with an Orangutan rather than a Baby Orangutan, Orangutan LV-168, or 3pi robot. F_CPU should be defined as the clock frequency of your target device in Hz. For the Orangutan this should be 8000000UL (8 MHz), while for the Orangutan LV-168, Baby Orangutan, and 3pi robot this should be 20000000UL (20 MHz). You can achieve this by commenting out line 3 and uncommenting line 2. If you don’t make this change, the timing of delayms() will be off.
- Make sure your Orangutan USB programmer is connected to your computer via its USB A to mini-B cable and then click the Display the ‘Connect’ Dialog button on the toolbar . You can also accomplish this by going to the Tools menu and selecting Program AVR -> Connect….
 | | Connecting to the programmer with AVR Studio |
|---|
- This will bring up a programmer selection dialog. The platform should be STK500 or AVRISP. The Orangutan USB programmer uses AVR ISP version 2 (written as AVRISPv2), but this is not the same as AVR ISP mkII. Here you select the serial port of your programmer if you know what it is, or you can select Auto and it will try all the ports until it detects the programmer. You can determine your programmer’s serial port by looking in the “Ports (COM & LPT)” list of your Device Manager for “Pololu USB-to-serial adapter”. Click “Connect…” to bring up the AVRISP dialog. You should see the green programming status LED flash very briefly as the dialog appears. If an error dialog appears instead of the AVRISP dialog, your computer cannot detect the programmer; please go to Troubleshooting (Section 7) for help identifying and fixing the problem.
 | | AVR Studio’s programmer-selection dialog |
|---|
- If you haven’t done so already, connect your programmer to your Orangutan or 3pi 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! You can test your connection by going to the Advanced tab (or, in the latest version of AVR Studio, the Main tab) and clicking the Read button in the Signature Bytes section. This sends a command to the target microcontroller asking for its device signature. If everything works correctly, you should see “Signature matches selected device”. If the signature does not match the selected device, you probably have the wrong device selected under the Program tab (or possibly your target device is turned off). If reading the signature fails entirely, please refer to our troubleshooting advice (Section 7) for help getting your connection working.
 | | AVR Studio’s Advanced AVRISP tab |
|---|
- Now it’s time to program your target device. Select the Program tab. Your Device should match the one you selected when you created the project: either ATmega168 or ATmega48 (note that in the latest version of AVR Studio, the device selector has moved to the Main tab). Your Input HEX File in the Flash section needs to be the hex file that was generated when you built your program. You can browse for this using the ”...” button to the right of the input file text box. If you navigate to your project’s folder, you should find it as “default\<project name>.hex”. Click the Program button (make sure you click the one in the “Flash” section, not the one in the “EEPROM” section!).
 | | AVR Studio’s Program AVRISP tab |
|---|
You should see both the red and the green programming status LEDs flicker on your Orangutan USB programmer as it programs and you should see the following text appear in the text box at the bottom of the Program window:
Reading FLASH input file.. OK
Entering programming mode.. OK!
Erasing device.. OK!
Programming FLASH .. OK!
Reading FLASH .. OK!
FLASH contents is equal to file.. OK
Leaving programming mode.. OK!
If there were no problems, the red LED on your Orangutan, Baby Orangutan, or 3pi should now be flashing! Note that if you trying this on a 3pi robot and you haven’t yet soldered in the optional through-hole LEDs, you will need to turn your 3pi robot over to see the flashing LED as the surface-mounted LEDs are located on the underside of the 3pi’s PCB. If there was a problem, please go to Troubleshooting (Section 7) for help identifying and fixing it.
Next:
5.b.
AVR Studio in More Detail
Previous:
5.
Getting Started Using Windows
|
|