3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Start-up Instructions for Programming Microcontrollers on a PC with WinAVR using an Atmega 328p Chip and USBTiny ISP Programmer for Examples

Start-up Instructions for Programming Microcontrollers on a PC with WinAVR using an Atmega 328p Chip and USBTiny ISP Programmer for Examples

This is more a gathering of information for ease of use than an outright Instructable. I’m not writing this as an expert on microcontrollers, I’m not. As a matter of fact, I know squat about microcontrollers. But I know programming. I originally created this in order to help someone who did know about microcontrollers to program his stuff and thought this might be helpful to others.
 
Remove these adsRemove these ads by Signing Up
 

Step 1Download and install WinAVR

Get the latest version at http://sourceforge.net/projects/winavr/files/WinAVR/ because I know some of the older versions don’t support either the m328p or the usbtiny. You will need to modify the Makefile examples that come with the software. The examples are located in the WinAVR\sample folder. Before we get to that, we need to create a place to store your projects. I suggest creating a “MyProjects” directory under “My Documents”. Within the “MyProjects” directory, create a folder for the current project you’re working on, in this example, I’ve created a “Jet Turbines” directory.

The home page for WinAVR information is http://winavr.sourceforge.net/. Installation is very straightforward, but there is additional, if not outdated and confusing, information located at http://winavr.sourceforge.net/install_config_WinAVR.pdf. WinAVR can be used in conjunction with AVR Studio. It can be downloaded at http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2725. Use of AVR Studio won’t be covered in this Instructable but its use is suggested because it has a simulator and allows step-through of your programs. A good tutorial on its use can be found at http://www.societyofrobots.com/member_tutorials/node/380, Submitted by Antonb on February 25, 2010 - 9:04am.

I’ll be using the USBtinyISP for the examples. It is a custom-make AVR programmer. The home page is http://www.ladyada.net/make/usbtinyisp/index.html. The microcontroller for the examples is an Atmega 328p http://www.atmel.com/dyn/products/product_card.asp?PN=ATmega328P. I will be referencing the datasheet for this controller located at http://www.atmel.com/dyn/resources/prod_documents/doc8271.pdf.

WinAVR comes with AVRDUDE. This is a downloader/uploader for microcontrollers. For testing on the command line, we need to know how to tell AVRDUDE what microcontroller and programmer we’re using, and what we want it to do. This information can be found at http://www.nongnu.org/avrdude/user-manual/avrdude_4.html#Option-Descriptions. The –p flag is the part number/microcontroller number. In this case, the ATmega328P is part number m328p. The -c flag is the programmer-id, in this case, usbtiny. Some other flags we’ll be dealing with are:
–e, this causes a chip erase to be executed, it’s basically a prerequisite command before the flash ROM can be reprogrammed again.
-U memtype:op:filename[:format], this performs a memory operation. In this case, I’ll be using the flash memory, and performing a w write operation, in the test case, using the test_leds.hex file, and in the final case, the main.hex file. I’ll use the default for the [:format].
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
2
Followers
3
Author:deyb1
I'm a geek and into all forms of DIY.