When using AVRStudio 4, there are some settings you’ll need to check before you can build a program and load code on your AVR:
First, the simulator wants to know what kind of a device you’re simulating. When you create a new project in AVRStudio and you get the list of available devices, this is what you’re actually setting.
In addition, you need to tell WinAVR what device you’re compiling for. This is done in the Project -> Configuration Options dialog. (This is also where you set your compiler optimization flags… more on that in a sec.)
In addition, you need to tell the AVR ISP Mk II what kind of a device it’s supposed to be writing to. This is done in the dialog box for the AVR ISP. It’s important, or the AVR ISP won’t be able to detect the target correctly and may report it as not existing at all.
In addition, there are two other values that need to be set in that dialog box. I don’t have my AVR ISP with me, so I can’t pull it up to look at where those settings live, but here’s the upshot: The programming speed needs to be set to some reasonable number. I’ve got mine set to 1MHz. Straight out of the box, I think my installation of AVR Studio was trying to program at something like 1kHz, which resulted in errors every single time. Also, it needs to know the voltage of the device. The AVR ISP Mk II can auto-detect the device voltage, but I forget how you tell it to do this. When I switched from doing an Orangutan to doing an AVR Butterfly, then back to the Orangutan, this setting tripped me up both times.
On compiler optimization settings: When it comes to compilation, you can optimize for speed or you can optimize for small binaries. Can’t optimize for both. In that Project -> Configuration Options dialog box, there’s a slot called “Optimization”. Far as I know all projects start out with a default of -O0. This makes for efficent and very large code. For smaller code try -O2, -O3, or -Os. When you compile, it’ll tell you the resulting size of the binary. Tweak away.
Why this is important: -O0 optimization tries to make things fast by expanding the code and having fewer branches. Makes for big code. It’s very easy to write a program that’s bigger than the memory on the Orangutan. Change the optimization flags and you can go from 110% memory usage down to 25%. The reason I mention it is if you’re trying to load your first program and things don’t work (which is what it sounds like is happening), this is just one more thing to be aware of and not get frustrated with.
Above all, don’t get discouraged! And if you get stuck, ask. Chances are it’s something someone else has run into as well.
Best of luck!
Tom