Professional Documents
Culture Documents
com/2010/10/23/avr-programming-introduction/
HOME BLOG
HACKADAY
HACKADAY.IO TORE HACKADAY PRIZE UBMIT ABOUT June 26, 2017
This tutorial series aims to make ou comfortable programming the Atmel AVR line of
microcontrollers. Whether ouve never touched a microcontroller before, or ouve cut
our teeth with dozens of Arduino projects, this will help ou get right down to the
hardware and give ou the confidence to build anthing.
1 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
This is a loaded question. For the sake of understanding Ill take this down to the most
simple explanation:
A microcontroller does what ou program it to do. It does so quickl, and reliabl. 14 Comments
Ive decided to use an ATmega168 microcontroller. Its a powerful chip but its no More from this categor
harder to start using than its ounger brethren. It will leave plent of room for ou to
2 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
grow into our projects, while remaining affordable (less than $4.50). Heres a diagram CATEGORIE
GO MALL,
YOURE THEGET
ONLY
BIG:
ONE
of it: NOT HACK
THE PLAYING
THAT
WITH
REVOLUTIONIZED
UNITY
elect Categor
40 Comments
11 Comments
OUR COLUMN
HACKADAY LINK: JUNE
25TH, 2017
10 Comments
Take a look at the pinout once again and look for the pins whose names start with PD. 203 Comments
You should see eight of them total, labeled PD0 through PD 7. This is a fantastic
PANELIZING BOARD
example of the 8-bit nature of these chips. PD stands for Port D, one of the input and THE EAY WAY
output register. Everthing in these chips centers around 8-bits. Thats a sequence of
21 Comments
eight 1s or zeros in different combination. If ou want to turn on or off specific features,
ou change one or more bits in a 8-bit register. Ever time ou want to change one pin
ou must address all eight in the register. Well learn much more about this but not until
More from this categor
the third part of the series.
Programming
3 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
its reprogrammable. In fact, when oure working on a project oull most likel teven Dufresne on DIY Raspberr Neural
reprogram it several times an hour. Network ees All, Recognizes ome
To get read for the rest of this tutorial series I need ou to gather some tools. You himm-jendrix on Hackada Prize Entr:
must have some tpe of computer, be it a Linux box, Mac, or Windows PC. This will run Messing Around With New Vacuum Tubes
software that takes our code, compiles it into something the microcontroller can use, notarealemail on Ambitious ATtin85 Board
and then tells a programmer how to write it to our chip. Tests a Beginners kills
4 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
Part 2: In the next installment of this series well take a look at several pieces of Garret chneider wrote a comment on TRON
hardware that ou can use to program an AVR microcontroller. Ive written a hello Discograph Project.
world program and will walk ou through building the circuit on a breadboard,
connecting the chip to a programmer, and using AVRdude to write this simple firmware
to the device. I dont want to get ou too excited, but this does involve a flashing LED.
Part 3: A pre-compiled HEX file was used to program the AVR microcontroller in Part 2
of the series. In this portion well look at the C language source code that made up that
firmware. Ill also talk in-depth about the peripherals available on the chip and detail
how to use them. Well finish up b adding functionalit to the original program,
recompile it, and reprogram the chip with the upgraded version.
Part 4: Now that ouve acquired AVR programming skills Ill show ou how to start
building cool stuff with them.
FOLLOW ME:
@szczs
5 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
profil sas:
October 23, 2010 at 9:11 am
Oh, nice!
Waiting for part 2 :)
6 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
Remlapw sas:
October 23, 2010 at 9:39 am
mess_maker sas:
October 23, 2010 at 9:34 am
I recentl decided to graduate mself from arduino to regular avrs and picked up an
avr dragon. Ive been working on m own little programs but am super excited to grab
info anwhere I can. Great idea for a series, I look forward to reading the rest.
teck_neeks sas:
October 23, 2010 at 9:48 am
nice, and gizmodo just started their own online classes for prototping our own
electronics.
Azdle sas:
October 23, 2010 at 9:49 am
Ed sas:
October 23, 2010 at 10:04 am
I have been waiting for something like this as I keep looking at various kits (arduino,
basic stamp etc) but Id rather learn how to build up something based around a micro-
7 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
No reall, this is great. I have waited for something like this to kick the last Arduino out
of m life
biased sas:
October 23, 2010 at 10:43 am
This is a great idea for a tutorial. Im looking forward to the next part of the series
because I plan on following it (Im completel new to this kind of stuff). Theres onl
question I cant seem to find the answer to immediatel. What hardware is used for
programming the ATmega168?
logan sas:
October 23, 2010 at 10:46 am
Awesome! Ive been wanting to use one of these, but have never taken the leap. Keep
up the good work!
Brian sas:
October 23, 2010 at 10:52 am
this is great!
mabe have an ARM one in the future? I can program AVR and PIC, but just the
8 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
choices for ARM and everthing is confusing and i dont know where to start
DMattox sas:
October 23, 2010 at 11:01 am
o Im prett good with arduino/done some breadboard AVR work with UBtinIP,
and Ive made we own hardware for specialized uses. Im sure this tutorial series (like
the android tutorials) will have some new stuff in them so I will read ever one. M
question of the da: will ou gus have an in between tutorial series? omething to
bridge the gap between Microcontrollers and Integrated Electronics? omething along
the lines of 32 bit MCU meets linux DIY? Mabe its just me, but this is the next step I
would like to take Beond pushing digital lines, mapping analog readings, and
having LEDs blink next to a nokia LCD.
patrick sas:
October 23, 2010 at 11:16 am
winavr is now inactive, see the post from the author here: http://www.arduino.cc
/cgi-bin/abb2/YaBB.pl?num=1277998302
elargo sas:
October 23, 2010 at 11:29 am
parkfun has a good avr tutorial for all of those waiting for part two.
9 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
harn sas:
October 23, 2010 at 11:52 am
Im also looking forward to the next part. Ive been programming on picaxes which are
fairl closed-source, but have eas cross-platform software available.. having a
beginners guide on programming AVRs (in Linux) will probabl convince me to switch.
M4CGYV3R sas:
October 23, 2010 at 11:56 am
WORD! All ou arduino zombies take note, this is how oure supposed to do it.
John sas:
October 23, 2010 at 11:57 am
This is awesome! As someone who has taught mself all I know about electronics and
microcontrollers, I know there are huge gaps in m understanding. Im looking forward
to gaining a better understanding of the basics!
matt sas:
October 23, 2010 at 12:01 pm
I agree with Brian: an ARM tutorial (with Linux instructions!) in the future would be
great. A side-b-side comparison of ARM development boards would be great too.
I like this AVR tutorial idea. Will it cover Makefiles? Keeping track of all the
command-line incantations can get confusing, and finding/writing a good Makefile can
be trick. (Ive been using the one that comes with V-UB as a base for a while.)
10 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
Banjohat sas:
October 23, 2010 at 12:08 pm
kestrel sas:
October 23, 2010 at 12:23 pm
For all ou people bashing Arduino, es, ou can do some ver cool stuff with just
straight AVR C. But at the same time, its just so much easier to develop things with
Arduino that theres no sense in abandoning one for the other. Its like saing that
writing in C is better than BAH scripting. There is a time and a place for each. I sa
keep both in our toolbox and use them when appropriate. For the most part, the
savings in time ou get when using Processing + Arduino makes it worthwhile to have
those tools available.
Gsta sas:
October 23, 2010 at 12:26 pm
beaglebreath sas:
October 23, 2010 at 12:27 pm
Thank ou HAD.
Ive needed a one stop tutorial to get me started with more advanced micros. Ive
been plaing with basic stamps and propellers forever, and have out grown them.
I hope ou will give a tutorial in detail to set up a cross-compiler using linux tools (with
examples that I can follow along with).
Also, I have never seen a good complete howto for ethernet communication from a c
to a compiled program in a pc. Im coveting a good tutorial which would explain the
11 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
whole communications path from the microcontroller through the internet and into a
program running on a pc (along with creation of a variable in a program).
Whoever sas:
October 23, 2010 at 12:39 pm
@beaglebreath
Ethernet isnt that big of a conceptual leap from asnchronous serial theres another
laer or two of housekeeping, but thats all. Youll need to understand buffering, but
everthing else is done for ou.
In the end, oure still just sending text and data back and forth like before its just
that ou have to specif a few more parameters needed b the IP protocol.
12 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
http://www.microcontroller.com/news/dallas_8051_ethernet.asp
As ou gus keep moving up the rungs of design complexit, it gets prett common to
simpl design a full linux sstem into whatever oure building. Once ou can run gcc
on it, ou can run anthing!
Henrik sas:
October 23, 2010 at 1:23 pm
Tech B. sas:
October 23, 2010 at 2:57 pm
Ajaxx sas:
October 23, 2010 at 3:51 pm
This is great!. I am so glad that ou are starting from the beginning because I am
basicall clueless with this stuff but reall want to learn.
I have to admit, as far as the prerequisites go, I do not understand how a breadboard
works but I will find out before lesson 2 arrives. In Jr. College I took a basic electronics
cours but when it came time to reading resistor rings I lost interest because I am color
blind. The instructor suggested I drop the class and I did. That was 26 ears ago and I
am convinced that todas electronics has a lot to learn without having to be able to
distinquish colors. Besides, all I need to do is ask a friend he, what color is this.
13 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
HUTECH sas:
October 23, 2010 at 3:52 pm
Akhil sas:
October 23, 2010 at 7:15 pm
1$ = Rs 50
beaglebreath sas:
October 23, 2010 at 7:50 pm
@ bilboa bob
i get what oure saing. thanks for the responce about the ethernetism.
at the moment ive been able to figure out how to serin/serout text to a wiz105cv
(serial to ethernet board) from m propeller. on m linux box i set up netcat to listen for
a connection. i then pipe the text from netcat into m compiled program.
ive no clue how to get the ethernet directl into m program. ive also tried a direct
connection using vb.net but had no success.
James sas:
October 23, 2010 at 7:51 pm
14 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
JA sas:
October 23, 2010 at 8:23 pm
ATMEL should designate someone titled master Yoda of electronics to write (or film)
tutorials for HaD about other stuff the make because the make a whole bunch of
goodies, including ARMs :P
aw4ll sas:
October 23, 2010 at 10:51 pm
Wouldnt this have been better on a 328? I heard somewhere that AVR werent
making the 168s anmore? I know the pin compatible but wouldnt ou want to use
that instead?
absolutezero sas:
October 23, 2010 at 11:41 pm
In part 2, please mention ArduinoIP! Those who are graduating from Arduino will not
need to invest mone in a programmer. From the environment the are alread
familiar with, the can upload the ArduinoIP sketch that will allow them to re-purpose
their Arduino as a general AVR programmer.
15 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
Adam sas:
October 24, 2010 at 1:19 am
there is nothing wrong with using an arduino in some situations. I agree with most
arduino bashers when ou rage over leaving a full board or a basicstamp with a
breadboard in a project. But I have no problem basing a project on an arduino,
especiall if i embed the chip on a custom board.
Ive programmed Freescale HC12s in assembl for a class and I used ATtin 85s in
AVR tudio C for m senior project. I never used an Atmega, but i would sa based on
the ATtins that the would be extremel powerful if ou knew how to control
everting.
The problem is interfacing with things like LCDs or extracting the exact serial
staments ou want from an GP NMEA output. If our code needs to be extreml fast
and efficient then go with AVR studio or even assembl. If our just building simple
things for fun then i sa go with arduino. Im working on a GP sstem to hunt for
Geocaches. Im going to build a custom board that will interface the
Atmega328/GP/LCD. The arduino alread has prebuilt libraries for lcd and gps and
makes it funner to build things like this. I I got most of the coding done in a couple
hours while watching tv.
btw its worth mentioning for part 2 that the AVRIP mkii programmers dont work with
Windows 7(not easil) the drivers dont work. There is a work around but it took me
several hours,lots of searching and man man installs/uninstalls of AVRGCC and
AVRstudio
Adam sas:
October 24, 2010 at 1:24 am
forgot to mention that i love the article so far and even though ive used the avrs
before, im looking forward to the other 3 parts and more like this to come
aw4ll sas:
October 24, 2010 at 2:54 am
@Adam I didnt have an trouble with the AVRIP MkII on Win7 at all, just straight plug
16 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
henrh sas:
October 24, 2010 at 3:03 am
Those looking for ARM tutorial should check out this link http://fun-tech.se/stm32/ got
me up and running ver quickl
Drone sas:
October 24, 2010 at 3:08 am
@Patrick, indeed WinAVR is inactive now. But it will work with the targets it supports
so-far and is nicel integrated with AVR tudio.
I read somewhere the person responsible for WinAVR was hired b ATMEL. I wonder if
it was to add C/C++ compatibilit to AVR tudio.
Cant wait for the second part of this tutorial to see if the recommended programmer
is one of those crippled nightmares from the likes of Adafruit.
One good thing, at least people arent being led down the Arduino path so far.
henrh sas:
October 24, 2010 at 4:30 am
17 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
development time or lower the barriers to entr. mbed vs NXP arm, arduino vs avr
atmega8 its comparing apples to apples and oranges to oranges, just a little sugar
was added, we all love sugar. Most things in Pthon,Perl,Rub could be done in C,C++,
or Java which could be done in assembl or machine code. I rarel reach for assembl
when I just want to *tr* an idea. Peace and love.
JA sas:
October 24, 2010 at 4:32 am
@Adam
Arduino bashing? I have managed to ignore such things or the dont bash it loud
enough that it could be heard under m rock.
But eah, Arduino is like iPhone. I dont mean to bash Arduino (its much more useful
and more value for the $ than i-anthing), let me explain:
one can bu add-ons to extend its capabilities and when new version comes along
ou just _have_ to have it. Yet somehow their main functions become irrelevant or
forgotten: new phone for calling people and Arduino for prototping purposes.
jockx sas:
October 24, 2010 at 6:59 am
AVRstudio is the wa to go on win. I never even heard of this WInAVR but b just
judging the qualit of the O projects latel I wouldnt waste m time on it. You
probabl just googled it.
You can reall sa a big thanks for Amtel providing all these stuffs for the hobbists,
microchips, avr programmers, cables, software.
There are a lot of different microcontrollers out there on different boards what ou
have no clue what the are. The use random meaningless numbers on the chips,
the dont have jtag or an programming interface, the might not even use an
standard code and not RIC.
18 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
ruzo sas:
October 24, 2010 at 7:12 am
WinAvr is the avr-gcc compiler to Avrtudio, without it ou can onl program assembl
in Avrtudio, people dont even know how too take full use of an AVR but want to use
one super complex ARM..
patrick sas:
October 24, 2010 at 7:44 am
@Drone, es i know that WinAVR works with the supported device, but i am not worr
about now, just a bit about the future (lets sa 1 ear). avrdude (part of winavr) will be
updated, so how we will have the last version? thats wh i am searching for an
alternative.
mogor sas:
October 24, 2010 at 9:13 am
Note that AVR tudio is the best free tools for debugging. Man hates AVR tudio but
ou must live with it if ou want to pla with JTAG or debuWire.
tkniques sas:
October 24, 2010 at 7:15 pm
Im looking forward to the next in this series. Ive been using PICs for ears have just
moved to AVRs in the last few months.
19 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
sanja sas:
October 24, 2010 at 7:59 pm
Instead of starting YAAT*, ou should have linked to one of the existing ones and
directed our energ toward Improving that one.
Phil sas:
October 25, 2010 at 1:34 am
To install the avr compiler and programmer bits on Fedora ou onl need to do this:
@Everone: Thanks for the encouraging comments. Part 2 is alread in the can and
scheduled to post toda.
Yes, Ill be talking about fuse bits. But not until part 3.
@anja: I think Yet Another AVR Tutorial is exactl what we need. Yes, there are
several out there, but different people understand things in different was. For people
that looked at all the other tutorials and kept on hitting a wall at one particular point
this ma be the answer for them. Or if not, whomever writes the next tutorial series
might address that knowledge gap.
20 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
James K sas:
October 25, 2010 at 6:04 am
@ARM Tutorials,
Ive developed both ARM and AVR series and it is far easier to build and do an AVR
tutorial than an ARM tutorial just too man pins and functions to cover.
James
Excellent tutorial Nooobs like me need this sort of stuff. Where else can we learn?
Keep up the good work HAD!
oipur sas:
October 28, 2010 at 2:27 pm
Jattends la partie 2 avec impatience ! Jai dj tout le matos. Plus qu entamer les
interruptions !
Newer Comments
Leave a Repl
21 of 22 27/06/17 06:01
AVR Programming 01: Introduction | Hackaday http://hackaday.com/2010/10/23/avr-programming-introduction/
Copright 2017 | Hackada, Hack A Da, and the kull and Wrenches Logo are Trademarks of Hackada.com
Powered b WordPress.com VIP
22 of 22 27/06/17 06:01