Sie sind auf Seite 1von 3

8/13/2014

Microcontroller - Program Transfer Part 1- A Beginners Guide to the Atmel AVR Atmega32
[ Log In ] [ Your Cart ]

LEARN THE FUNDAMENTALS OF MECHATRONICS!


Home

Products

Microcontroller tutorial

Video Clip Search - Be Descriptive.

Microcontroller - Intro
MCU Programmer 1

Show and Tell

About Us

Contact Us

Site Map

Add a Video Clip

GO

C# Notes and Examples

Donate

Microcontrollers - Creating an SPI Interface from the Programmer to the


Microcontroller to Make Transferring More Convenient

MCU Programmer 2

Atmega324P

MCU WinAVR Install

$8.50

MCU Add LED and Test

Qty: 1

MCU First Program

Add to Cart

MCU LED Blink


Installing Atmel Studio 6
MCU Add a Button

Microcontroller
Beginner Kit

Button Debouncing
Software Debounce

$39.95

The Button Game

Qty: 1
Add to Cart

Creating a Button Library


Timers Counters Basic
Intro to Interrupts
Interfacing an LCD

USB Cable Type A


Male to USB Type
A Male - 3 FT

First LCD Program


LCD and Strings

$2.65

Numbers on the LCD

Qty: 1

Separating the LCD Code

Add to Cart

Function to Display Integers


Power Sources
Making Connectors
Potentiometers

USB 2.0 Cable


Type A Male to
Type B Male - 10
FT

Intro to ADC
ADC - First Program

$4.80

ADC and 10-Bits

Qty: 1

Accelerometers/ADC

Add to Cart

Measure ADC Noise


ADC Multiple Channels
Intro to Hobby Servos
Intro to PWM
Control a Servo with PWM
UART and USART Details
UART One Way Comm.
Controlling Digital Servos

Cables And Wires


Capacitors
Connectors
Crystal Oscillators

So, at this point, you should be familiar with the concept of


the microcontroller (MCU). You should also have an
appreciation for the general uses of the microcontroller.
You have a basic understanding of the pin assignment and
the Ports. And, hopefully, you are excited with what a
microcontroller can do, like sensing and controlling the
environment. Finally, you know that we will get into the
programming side of things--given the title of this page,
and the fact that we touched on it in the introduction).
Now we will need to get more in-depth with the programming. However before we can get a program loaded
onto the chip, we need a good way to connect the SPI (Serial Peripheral Interface) connector to the chip. We
couldn't very well shove the connector into the pins of the microcontroller, now could we? And sticking wires in
the end of the connector and into the breadboard is flimsy, unattractive, and possibly harmful to the MCU if a
wire carrying voltage is accidentally applied to the wrong pin.

Breadboard
Connector for the
8 Channel Logic
Analyzer

$9.95
Qty: 1
Add to Cart

Therefore to maximize our chance of success and standardize each and every connection attempt, we will

https://www.newbiehack.com/MicrocontrollerProgramTransferPart1ABeginnersGuidetotheAtmelAVRAtmega32.aspx

1/3

8/13/2014
Development Tools
Input Devices
Integrated Circuits
Interfaces
Kits
LCD Displays And Leds

Microcontroller - Program Transfer Part 1- A Beginners Guide to the Atmel AVR Atmega32
construct a small board that contains a header (little metal
pins that stick up) that the SPI connector can use, and also
a header that will correspond to the appropriate pins on
the microcontroller. The latter can simply be a single row of
six pins since the makers of the Atmel AVR Atmega32
microcontroller so thoughtfully located these pins together.
This will allow us to make our MCU interface board with a
very narrow size, which will reduce the area covered on the
breadboard (as can be seen in the video). Oh yeah, the
video contains a bit of soldering, so you can learn that too!

Microcontroller

Ok,
so to

Motor Drivers

USB AVR
Programmer

$9.95
Qty: 1

Add to Cart

USB to Serial
Converter

Motors

$19.95

Potentiometers

Qty: 1
Add to Cart

Power
Prototyping
Resistors
Sensors

Bundle of 65 Male
to Male Flexible
Jumper Wires

Voltage Regulators

$8.95
Qty: 1

Add to Cart

reiterate from the last tutorial, there is a programmer that is needed between the computer and the
microcontroller. It should be noted that there are several different programmers that can be used, and a suitable
model can be had from either Adafruit Industries (USBTinyISP) or Sparkfun (Pocket AVR). Some of these
programmers look totally different from others, but all of them basically do the same thing--provide an interface
between the computer and the AVR microcontroller. That's it! Note that if you are not using the AVR Atmega32
microcontroller, then you must check the compatibility of the programmer you choose to use. Also note that
many of these programmers use the same drivers, an issue which we will get to in the next tutorial.
The connection between the computer and the MCU is really quite simple, so there should be no reason to be
afraid of (or timid with) doing these steps to get a program into the microcontroller. So, let's get to it!
Remember that the purpose of making such an interface board, is to insure a proper connection each and every
time we need to load our program into the MCU. So if you want to make a board like I've shown in the video,
then just get out your soldering iron. Don't be afraid, get it out! Well, you should be careful, as it gets hot. But
don't let that get in your way. Just make sure to read all of the manufacturer's instructions on the proper
operation of the soldering iron. Also, don't forget to wear goggles; and don't breath the solder fumes. Some
people use a suction fan to get the fumes away from the workspace.
Check out the diagram above. Yes, it's a bit messy, but I drew this while caffeine was flowing through my system!
The SPI connector pin-out is to the left. There are arrows from this SPI interface block to the corresponding pins
on the AVR Atmega32 microcontroller. There will be no need for fancy components to complicated this process,
so don't worry--we are only connecting wires from the SPI device to the pins of the microcontroller.
Let's run through the connections between the SPI device and the MCU:
Top left SPI pin is connected to the MISO (Master In Slave Out)
Middle Left SPI pin is connected to the SCK (the clock pin)
Bottom Left SPI pin is connected to the Reset (Reset just does exactly what is says, and you can be sure we
will talk about this pin later!)
Bottom Right SPI pin is connected to the GND (Ground, or zero volts)
Middle Right SPI pin is connected to the MOSI (Master Out Slave In)
Top Right SPI pin is connected to the VCC (+5 Volts, if you want, you can go check voltage requirements in
the summary, or the HUGE manual, and trust me, this is not an easy read!).

40 pin IC Socket

$0.89
Qty: 1

Add to Cart

3 position female
connector with
2.54mm pitch

$0.55
Qty: 1

Add to Cart

That's it!! All you need to do now is solder the wires


between the two sets of headers (remember this term?
They're just pins that stick up and insert into a female
header). Note that the picture near the top of this page
shows the female header plugged into the male header.
Once these wires are all connected and soldered-up, it
should look something like these pictures. However, if you
want to get crazy and do it differently, please go for it!! I
encourage creativity.
As can be seen in the pictures, the connections from the
wires to the headers are made using solder bridges. A
solder bridge is just solder that "blobs" together to
connect two locations. These blobs sort of look like little
figure 8's, or infinity symbols. And, it's not too hard to
create these bridges. All you need to do is solder the two
wire/pin connections like normal, and then add just a little
more solder while holding the iron over both of the

https://www.newbiehack.com/MicrocontrollerProgramTransferPart1ABeginnersGuidetotheAtmelAVRAtmega32.aspx

2/3

8/13/2014

Microcontroller - Program Transfer Part 1- A Beginners Guide to the Atmel AVR Atmega32
connections. This will provide enough solder to create the
bridge. However, there is the possibility that they won't
bridge. Ah, the bane of existence for most solderers...! The
bridge is generally not advised in most applications; but in
this case, it's simply the easiest way to make the
connections between the SPI and MCU pins, and the
corresponding wires that connect them. Once you have
enough solder applied, and the hot iron is over the two
connection, pull the iron straight up along the pin and the
bridge should be maintained. Otherwise you may destroy
the bridge if the hot iron is allowed to once again make
contact with the main body of the bridge. Don't worry--the
video shows this very nicely, and you should get the hang
of it pretty quickly.
So, wasn't that easy? Now, we will get into the software
part of it in the next tutorial. We will find the software on
the internet to: First, recognize and drive the USBTinyISP
programmer (or, if you choose, the Pocket AVR
Programmer); and second, install the development
environment. Note that by "driver," I mean to install a driver
under the Windows OS, and the "development environment" is
simply the application you will use to write the programs that
will later be transferred to the chip. If you are using installing
this program on another OS, like Linux or the Mac, you will
still be able to follow along. Here and there, I may speak of
those other wonderful operating systems and how to do
things (or find the resources that will help). The
programming is the same, but the development
environment will probably be slightly different.

Find us on Google+

https://www.newbiehack.com/MicrocontrollerProgramTransferPart1ABeginnersGuidetotheAtmelAVRAtmega32.aspx

3/3