0% found this document useful (0 votes)
92 views13 pages

Introduction To The Atmel Atmega16 Microcontroller: Learning Objectives

A microcontroller often ser!es as the / brain0 of a mechatronic system% 1i2e a mini, self-contained com"uter, it can be "rogrammed to interact $ith both the hard$are of the system and the user% 3!en the most basic microcontroller can "erform sim"le math o"erations, control digital out"uts, and monitor digital in"ut% 4ost modern microcontrollers

Uploaded by

raj4110640
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views13 pages

Introduction To The Atmel Atmega16 Microcontroller: Learning Objectives

A microcontroller often ser!es as the / brain0 of a mechatronic system% 1i2e a mini, self-contained com"uter, it can be "rogrammed to interact $ith both the hard$are of the system and the user% 3!en the most basic microcontroller can "erform sim"le math o"erations, control digital out"uts, and monitor digital in"ut% 4ost modern microcontrollers

Uploaded by

raj4110640
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 13

Introduction to the ATmega16

Atmel - 1

Introduction to the Atmel ATmega16 Microcontroller


Learning Objectives: At the end of this lab you should be able to: Identify the Atmel ATmega16 microcontroller, STK500 e!elo"ment #oard, and associated hard$are% &reate a ne$ "ro'ect in A() Studio, and "o"ulate the "ro'ect $ith "re-e*isting code% +se A() Studio to com"ile code in A,SI &% +se A() Studio to "rogram the ATmega16 microcontroller% -ty% 1 1 1 1 1 . Item Atmel ATmega16 microcontroller mounted to an STK500 development board Serial programming cable 1. ( & "o$er su""ly 6-"in ribbon cable .-$ire female-female 'um"er 10-$ire female-female 'um"er

Components:

Introduction A microcontroller often ser!es as the /brain0 of a mechatronic system% 1i2e a mini, self-contained com"uter, it can be "rogrammed to interact $ith both the hard$are of the system and the user% 3!en the most basic microcontroller can "erform sim"le math o"erations, control digital out"uts, and monitor digital in"uts% As the com"uter industry has e!ol!ed, so has the technology associated $ith microcontrollers% ,e$er microcontrollers are much faster, ha!e more memory, and ha!e a host of in"ut and out"ut features that d$arf the ability of earlier models% 4ost modern controllers ha!e analog-to-digital con!erters, high-s"eed timers and counters, interru"t ca"abilities, out"uts that can be "ulse-$idth modulated, serial communication "orts, etc% The microcontroller and the de!elo"ment board used in this lab $ere donated by Atmel for your use% In industry, you can e*"ect to "ay any$here from 550 to 5600 for 'ust a de!elo"ment board and u" to 51000 for a "rofessional com"iler and "rogramming interface7 SO ! CA"!#$L A%& "!S'!CT#$L of the microcontrollers and de!elo"ment boards7 1i2e any electronic de!ice, they are delicate and may be easily damaged7 ! !S'!CIALL( CA"!#$L of static charges7 #efore you touch the STK500 board 8or any other circuit board $ith integrated circuits, for that matter9, ma2e sure that you ha!e dissi"ated any static charge that has accumulated on your body% The best $ay to do this is by using an 3S $rist stra" that has been connected to a good earth ground and by "lacing your circuit board on a grounded 3S mat% If you don:t ha!e these 3S su""lies, touch a $ell-grounded metal surface before you handle the circuit board% The bottom line is: $S! COMMO% S!%S!) and #OLLO* T+! I%ST"$CTIO%S in the lab assignments% ;ou $ill build upon your experience from each lab, and you are therefore encouraged to learn as much as you can from each e*"eriment and its e*am"les% The ATmega16 Microcontroller The ATmega16 microcontroller used in this lab is a 60-"in $ide I< 8&ual In Line9 "ac2age chi"% This chi" $as selected because it is robust, and the I< "ac2age interfaces $ith "rototy"ing su""lies li2e solderless bread boards and solder-ty"e "erf-boards% This same microcontroller is a!ailable in a

San =os> State +ni!ersity e"t% of 4echanical and Aeros"ace 3ngineering

re!% ?%6

06S3<.010

Introduction to the ATmega16

Atmel - .

surface mount "ac2age, about the si@e of a dime% Surface mount de!ices are more useful for circuit boards built for mass "roduction% Aigure 1 belo$ sho$s the B"in-out: diagram of the ATmega16% This diagram is !ery useful, because it tells you $here "o$er and ground should be connected, $hich "ins tie to $hich functional hard$are, etc%

#igure 1, ATmega16 'in-out diagram, ,otice that some of the "ins ha!e alternate functions 8sho$n in "arentheses9%

Throughout the semester, you $ill need to 2no$ things about the ATmega16 8or other com"onents9 that are not co!ered in the lab instructions% Therefore it is im"ortant that you become familiar $ith documentation a!ailable from !arious sources% (our .irst tas/ is to locate the ATmega16 manual) and save it .or 0oursel. .or .uture re.erence% It can be found in a "df format on Atmel:s $ebsite 8$$$%atmel%com9, A()Area2s 8htt":CC$$$%a!rfrea2s%netC9, or by searching the $eb% Arom the manual, you can find information about the ATmega16:s features and ho$ to use them% +o1 man0 channels o. 12-bit A3& converters are there4 +o1 man0 b0tes o. in-s0stem reprogrammable .lash are there4 ST5 622 Inter.ace oard The hard$are that you $ill use consists of the STK500 de!elo"ment board% The SKT500 can actually be used $ith any of the microcontrollers in the A() family 8see the STK500 user guide9% It allo$s a user to $or2 $ith many different Atmel microcontrollers and easily gain access to their ICD "ins% The STK500 has t$o serial "ort connectors 8one for "rogramming the de!ices and one as a s"are )S.?. "ort9, a "o$er su""ly s$itch and connector, eight 13 s and eight s$itches for general

San =os> State +ni!ersity e"t% of 4echanical and Aeros"ace 3ngineering

re!% ?%6

06S3<.010

Introduction to the ATmega16

Atmel - ?

use, and !arious 'um"ers for configuring the board% Aigure . sho$s a to" !ie$ of the STK500 interface board and the location of some of the hard$are elements that you $ill use%

Figure 2. STK500 development board. This is a universal development board for AVR microcontrollers. Note the location of the features as indicated by the arrows.

#efore you go further in the "rocedure, double-chec2 the default 'um"er settings on the STK500 as sho$n in Aigure ?%
8umper (TA)F3T A)3A )3S3T GTA11 DS&S31 #S31. Setting D, D, D, D, Dn-board cloc2 DAA

8umper Setting &e.inition

D,

DAA

#igure 7, &e.ault jumper settings on the ST5622, A 'um"er consists of t$o female soc2ets tied together internally $ith a metal conductor and surrounded by a "lastic housing% Ty"ically, $hen the "ins are connected, the 'um"er is considered to be in the D, "osition% Ehen setting a 'um"er in the DAA "osition, "lace the 'um"er on only one of the t$o "ins% This $ay the 'um"er does not get lost and is a!ailable in case you need to change its setting% The 'um"er for DS&S31 is set so that it connects the t$o right-most "ins of the three% Thus set, it selects the on-board cloc2 signal%

;ou $ill be using the IS< "rogramming mode for communicating $ith and do$nloading your "rograms to the microcontroller% As a result, you need to connect the 6-"in IS< ribbon cable from

San =os> State +ni!ersity e"t% of 4echanical and Aeros"ace 3ngineering

re!% ?%6

06S3<.010

Introduction to the ATmega16

Atmel - 6

the IS<6<I, header on the STK500 to the 6-"in S<)DF? header outlined in red abo!e it% Aigure 6 sho$s this connection on the STK500% ! S$"! to line u" the red, "in1 stri"e on the ribbon cable to "in 1 on each header% After com"leting this connection, the STK500 interface board should be ready for use in your labs%

#igure 9, 6-'in IS' ribbon cable connection .or programming the ATmega16, &onnect the IS<6<I, header set on the STK500 to the S<)DF? header set outlined in red using the 6-"in IS< ribbon cable% 4a2e sure that you orient the red stri"e on the cable, so that it connects to "in 1 on both header sets%

*inA:" There are se!eral $ays that you can $rite, com"ile, and do$nload a "rogram to the ATmega16 microcontroller% There are many different te*t editors, com"ilers, and utilities a!ailable for many different languages 8&, #ASI&, assembly language, etc%9% Some of these are free of charge, and some reHuire a licensing fee to use them% In this class, $e $ill use a free$are "ac2age of soft$are tools named EinA() 8"ronounced, /$hene!er09% EinA() has been installed on the com"uters in the 4echatronics 1aboratory, but you are strongly encouraged to do$nload it and install it on your o$n com"uter, so you can $or2 $ith your microcontroller outside of the lab% Instructions for installing EinA() are gi!en in A""endi* A at the end of this document% EinA() consists of a suite of e*ecutable, o"en source soft$are de!elo"ment tools for the Atmel A() series of )IS& micro"rocessors hosted on the Eindo$s "latform% It includes the F,+ F&& com"iler for & and &II, $hich is sometimes referred to as a!r-gcc% Traditionally, the microcontroller in embedded systems $as "rogrammed directly using assembly language% Assembly language uses only the basic instruction set for a "articular microcontroller% Ehile this can "roduce fast, efficient code, it is limited in that e!ery "rocessor ty"e has its o$n instruction set% Therefore it is not a "ractical language to learn unless you are doing a "ro'ect that is dedicated to a s"ecific microcontroller or has a real need for "recise timing andCor memory use% The & language, on the other hand, is commonly used in industry and can be a""lied o!er many different "latforms% #y learning this one language, you $ill be able to "rogram almost any microcontroller, "ro!ided that you ha!e a com"iler that can translate & code into assembly language for your controller% The Fnu-& com"iler is an o"en-source, free$are, & com"iler that forms the basis for com"ilers that generate code for many different microcontrollers and !arious o"erating systems, such as Eindo$s and +,IG% A:"#"!A5S Are !ver01here; A!rArea2s%com 8htt":CC$$$%a!rfrea2s%netC9 is a $ebsite de!oted entirely to the A() "rocessors from Atmel% It contains lin2s to do$nload locations for the most recent !ersion of soft$are, current information regarding ne$ and old "rocessors from Atmel 8including user manuals, technical $hite

San =os> State +ni!ersity e"t% of 4echanical and Aeros"ace 3ngineering

re!% ?%6

06S3<.010

Introduction to the ATmega16

Atmel - 5

"a"ers, etc%9, message boards for "eo"le 'ust li2e you $ho ha!e Huestions, and general information regarding com"ilers, "rogramming interfaces, etc% This $ebsite can be a useful tool $hen de!elo"ing or troubleshooting "ro'ects $ith the ATmega16% 4uch of the site can be accessed by anyoneJ ho$e!er, to access some of the message boards and do$nloadable items, you must register a username% on:t $orry, it:s free7 <o to Avr#rea/s,net no1 and register a username .or 0oursel., *rite do1n 0our A:"#rea/s username and turn it in 1ith the rest o. 0our lab 1rite-up, K#efore you "ost a Huestion on any of the A()frea2s forums 8or any other $eb forum for that matter9, you are strongly urged to read 3ric )aymond:s famous $eb "ost: /Lo$ to As2 -uestions the Smart Eay0, $hich is a!ailable at: htt":CCcatb%orgCesrCfaHsCsmart-Huestions%html%M 'rocedure ,o$, you:ll begin building your first "ro'ect% Aor this first "ro'ect, you $ill use an e*am"le "rogram "ro!ided for you that demonstrates ho$ to "rint messages to the serial "ort% Try to remember these ste"s, because you $ill need to go through them in subseHuent labs% The more familiar you are $ith these ste"s, the faster the labs $ill go in the future% ;ou $ill be using a free$are "rogram from Atmel called A() Studio to organi@e all the files needed to com"ile a "rogram to run on the microcontroller% The ne*t fe$ ste"s $ill lead you through the "rocess of setting u" a file structure, $hich $ill contain the needed files% K,ote that the com"uters in the 4echatronics lab already ha!e A() Studio and EinA() installed on them% If you $ant to $or2 on a microcontroller outside the lab, you $ill need to install this soft$are on your o$n com"uter% See A""endi* A at the end of this document for instructions%M 1% D"en A:" Studio by double-clic2ing its icon on your des2to" or selecting it in the Start 4enu% .% Select 'roject -= %e1 'roject from the dro" do$n menus or ,e$ <ro'ect from the "o"-u" $indo$ if one o"ens $hen you launch A() Studio% ;ou should see the ne$ "ro'ect $indo$ as sho$n in Aigure 5%

#igure 6, A:" Studio %e1 'roject 1indo1, ,ote the settings used for this lab and the location $here your folder $ill be created%

?% In the ne$ "ro'ect "o"-u" $indo$:

Select A:" <CC and ty"e a descri"ti!e name into the 'roject name field 8li2e AirstA()"ro'ect9% Since you $ill be using "ro!ided source code unchec2 the Create initial .ile bo*%

San =os> State +ni!ersity e"t% of 4echanical and Aeros"ace 3ngineering

re!% ?%6

06S3<.010

Introduction to the ATmega16

Atmel - 6

&hec2 the Create .older bo*% #ro$se to ensure that the 1ocation 8$here your "ro'ect $ill be sa!ed9 already e*ists, so that you are a$are of $here you are sa!ing files% #e sure to e!entually co"y your "ro'ect files onto a +S# dri!e or email your source files to yourself, because any files left on the lab com"uters may be modified or deleted at any time% &lic2 the %e>t NN button Select A:" Simulator in the &ebug plat.orm field% Select ATmega16 ?not ATmega16A@ in the &evice field% 8scroll do$n, it is there9 &lic2 the #inish button

6% &onfigure your "ro'ect settings using the 'roject -= Con.iguration Options dro" do$n menu as sho$n in Aigure 6% &hange the #reAuenc0 bo* to B222222% 8O million $ithout the commas% ,ote that if you get an error regarding AP&<+ undefined, it is because you forgot this ste"%9 &hange the OptimiCation bo* to DOE% &lic2 on the Include &irectories button found on the left side% &lic2 on the ,e$ Aolder icon 8u""er right corner9 and use the bro$se elli"se /Q0 to add your "ro'ect folder you created in Ste" R? 8a""ears as %S 9 &lic2 DK

#igure 6, 'roject con.iguration options% Any time you create a "ro'ect using A() Studio, you should set the AreHuency and D"timi@ation as sho$n abo!e to the left% ;ou also need to include the directory that you ha!e your source code in 8denoted %S 9 by going to the Include irectories o"tion, adding it as a ne$ folder, and bro$sing to $here it is on the <& as sho$n abo!e to the right% If you use code from some other "ro'ect directory or library, you $ill need to include the location of $here their directories reside% In the e*am"le abo!e, A()lib $as also included% ;ou do not need A()lib for this laboratory%

5% ,o$ na!igate to the class $ebsite, and do$nload the code for this lab% Sa!e the files into the "ro'ect file that you created in ste" ?% The reHuired files are: uart%c uart%h mainPintro%c

This code is meant to sho$ you ho$ to send strings of te*t from the microcontroller to another de!ice, in this case a <&% The "rotocol being used is )S-.?. serial% Aor more information on )S.?., see:

San =os> State +ni!ersity e"t% of 4echanical and Aeros"ace 3ngineering

re!% ?%6

06S3<.010

Introduction to the ATmega16

Atmel - T

htt":CCen%$i2i"edia%orgC$i2iC)S-.?. )S-.?. communication $ill allo$ us to send binary data bet$een t$o "oints, and this $ill be useful throughout the semester in debugging "rograms or communicating $ith e*ternal chi"s, li2e sensors or e!en other microcontrollers% ,o$ go to the <ro'ect irectory $indo$ on the left hand side of the screen as sho$n in Aigure T, right-clic2 on the Source Ailes folder icon, and select BAdd 3*isting Source Aile8s9:% In the resulting dialog bo*, select uart%c and mainPintro%c 8clic2 on one of the file names, then hold the &T)1 2ey do$n, and select the other9, then clic2 DK% Add uart%h into the Leader Ailes folder follo$ing a similar "rocedure, but first right-clic2ing on the Leader Ailes folder icon%

#igure F, Adding source .iles% ;ou need to add the & source and header files into the a""ro"riate "ro'ect folders%

6. ;ou are no$ ready to com"ile your first "ro'ect7 Arom the main menu select uild uild% 8;ou can also use AT or the #uild button on the toolbar in the future9% B#uild: com"iles your "rogram% If you ha!e any errors, correct them before "roceeding% 4essages from the com"iler $ill a""ear in the bottom 8#uild9 $indo$ of A() Studio% If you double-clic2 on a line in this $indo$ that indicates an error, it $ill ta2e you to the offending line in your "rogram% As2 a TA for hel" if necessary% Al$ays chec2 the #uild log $indo$ to ensure that the last message states that there are no errors before going further% If you had errors, and you fi* them, it is ad!isable to run the B&lean: routine that $ill get rid of files generated from any "re!ious attem"ts to build your "ro'ect% So, $hen needed, select uild Clean from the Tools dro"-do$n menu 8or use AT or the button on toolbar in the future9 to run &lean% T% ;ou are almost ready to do$nload your "rogram to the ATmega16 microcontroller7 &onnect the serial cable from &D41 on your com"uter to the )S.?. &T)1 connector on the STK500 board 8the connector closest to the "o$er 'ac29% &onnect "o$er to the STK500, and turn on the board $ith the "o$er s$itch in the u""er right hand corner% If the board is functioning "ro"erly you should see green lights abo!e (TA)F3T and STAT+S% O% In A() Studio, select the A() <rogram button as sho$n in Aigure O 8or use Tools --N <rogram A()9% A message in the bottom of this $indo$ should indicate that you are connected to your "rocessor% If the message indicates that detection of your controller failed, double-chec2 your "o$er and serial cable connections and try again% If you still ha!e "roblems, get hel" from your lab instructor%

#igure B, A:" 'rogrammer Toolbar, &lic2ing the B&onnect: button $ill o"en the STK500 <rogramming ialog #o*% If you see a bo* that "ro!ides you $ith a list of a!ailable "rogramming hard$are, ma2e sure that your STK500 is connected and "o$ered on, and then select /STK5000 and /Auto%0

San =os> State +ni!ersity e"t% of 4echanical and Aeros"ace 3ngineering

re!% ?%6

06S3<.010

Introduction to the ATmega16

Atmel - O

,o$ select the #use tab, and chec2 that the fuses are set "ro"erly, as listed in Table 1 and sho$n in Aigure U% Auses are bits in the ATmega16 33<)D4 that deal $ith such things as the cloc2 source, oscillator o"tions, bro$n-out detection, etc% Aor more information on fuse bits, see the a""ro"riate "ages in the ATmega16 manual% The fuse bits only need to be "rogrammed once%
Table 1. Fuse Settings for the ATmega16. Make sure that these are set so that your ATmega16 works properly! Since we are not using a bootloader, it probably wont matter for any of the programs that you write in ME 106 what Boot Flash section size you choose. Choosing the smallest value will give the most space for your program code, however

Fuse Settings to be Checked for the ATmega16 Microcontroller Boot Flash section size=256 words Boot start address=$1F00; or Boot Flash section size=512 words Boot start address=$1E00; Brown-out detection level at VCC=2.7 V; Int. RC Osc. 8MHz: Start-up time: 6 CK + 0 ms;

#igure G, A:" #use Selection, These fuses need only to be set the first time a ne$ chi" is used%

U% ,o$ select the +* Settings tab, and !erify that the STK500 cloc2 generator freHuency is set to ?%6O6 4L@ and that the IS< freHuency field is LESS THAN 1C6 of the ATmega16:s cloc2 s"eed 8the ATmegaVs internal cloc2 is set at O 4L@, so the 1%O6? 4L@ should $or2 fine%9 The right side of Aigure 10 sho$s the LE Settings tab, and the left side sho$s the 4ain tab $here the IS< freHuency can be selected% If you made changes to the fuse settings or IS< freHuency, "ress, B<rogram: to burn the fuses to the ATmega16%

San =os> State +ni!ersity e"t% of 4echanical and Aeros"ace 3ngineering

re!% ?%6

06S3<.010

Introduction to the ATmega16

Atmel - U

#igure 12, ST5622 IS' settings and hard1are settings, IS< 8In System <rogramming9 is the communication "rotocol that the STK500 uses to "rogram the AT4ega16% If the IS< freHuency is set too high, then communication errors $ill occur% If the IS< freHuency is set too lo$, it $ill ta2e a long time for your "rogram to be do$nloaded to the microcontroller%

If both your )S-.?. cable A, 6-"in 'um"ers are installed "ro"erly, and you get a dialog bo* titled, /IS< 4ode 3rror0 $ith some !erbiage li2e, /A "roblem occurredQ0, !erify that: ;our STK500 is turned on% The serial cable is connected to the W)S-.?.W 8not WS<A)3W9 labeled U-"in connector% The 6-"in ribbon cable is connected bet$een the IS<6<I, and S<)DF? headers Ly"erterminal is not connected to the &D4 "ort that is shared $ith A() Studio for "rogramming% If the "roblem "ersists, see A""endi* # for another "ossible solution% 10% ,o$ you:re ready to do$nload the "rogram to the chi"7 See Aigure 11 belo$% Select the 'rogram tab% +nder the Alash section, use the bro$se button 8/Q09 ne*t to the BIn"ut L3G file: dialog bo* to select the he* file associated $ith your "rogram% ;ou:ll find it by going to the folder you created, and o"ening the default folder% The he* file $ill ha!e a %he* e*tension% The he* file contains the com"lied "rogram translated into byte code that is readable by the microcontroller% &lic2 on the <rogram button $ithin the Alash section to do$nload the he* file to the microcontroller% ;ou $ill see the "rogress bar u"date for a second or t$o, and you should see a series of BDK: messages% If any of these messages are not, BDK:, you may ha!e to as2 your lab instructor for hel"% 11% ,o$ that you ha!e do$nloaded your "rogram, it should be running7 To !erify this, you:ll use Ly"erTerminal to ca"ture the out"ut of your "rogram to the monitor of the <&% <o$er off the STK500 using the "o$er s$itch% isconnect your serial cable from the )S.?. &T)1 connector, and reconnect it to the )S.?. S<A)3 connector on the STK500 board% Ee also need to connect the transmit and recei!e "ins from the ATmega16:s +A)T0 "ort to the )S.?. S<A)3 connector:s transmit and recei!e "ins% +se the t$o-$ire 'um"er "ro!ided $ith your lab 2it to connect the < 0 and < 1 "ins of the <D)T header to the )G and TG "ins

San =os> State +ni!ersity e"t% of 4echanical and Aeros"ace 3ngineering

re!% ?%6

06S3<.010

Introduction to the ATmega16

Atmel - 10

8)3S<3&TI(31;7 i%e%, '&2 connects to "H&) and '&1 connects to TH&9 of the )S.?. S<A)3 header on the STK500 board% Aigure 1. sho$s this connection% %ote: (ou 1ill not see output on the serial port unless 0ou ma/e this connection; 81oo2 in the ATmega16 manual to see the Alternate Aunctions of the <D)T "ins9% Aor this lab $e $ill also use t$o 10-"in ribbon cable 'um"ers, one to connect the 10-"in SEIT&L3S header $ith the 10-"in <D)TA L3A 3), and the other to connect the 13 header $ith the <D)T# header% Ehen ma2ing these connections, ma2e sure that the red stri"e connects "in 1 at each header on both ends of the 'um"er% See Aigure 1. for the "ro"er connection%

3!ery time you "rogram the microcontroller, 4AK3 S+)3 that this bo* contains the "ath to the he* file that you $ant to do$nload% It is !ery easy to forget this $hen you change "ro'ects%

#igure 11, ST5622 programming dialog bo>, ,ote that $hen you create a ne$ "ro'ect, the In"ut Le* Aile does NOT automatically get u"dated to match your ne$ "ro'ect settings% Therefore, it is im"ortant ma2e sure the desired L3G file is selected e!ery time you o"en or create a ne$ "ro'ect%

,o$ o"en a serial communications "rogram such as Ly"erTerminal 8$hich can be found under Start All <rograms Accessories &ommunications9% If you are as2ed to name a ,e$ &onnection, enter any name you $ant, and "ress DK% Select &D41 for, /&onnect +sing0, and "ress DK% Set &D41 "ro"erties $ith: U600, O, ,, 1, ,, then "ress DK% <o$er on the microcontroller, and "ress the reset button on the STK500% *hat is displa0ed on 0our screen4 Is this 1hat 0ou e>pected4 1.% ;ou should obser!e that the floating "oint number is not dis"layed "ro"erly% )ead the comments in the uart%h "rogram header file to find out ho$ to correct this issue% 13. #ecause you ha!e changed com"iler o"tions, you must do a, #uild &lean, before rebuilding your "ro'ect% ,o$ rebuild your "ro'ect $ith, #uild #uild, and re-do$nload and re-run your "rogram as before%

San =os> State +ni!ersity e"t% of 4echanical and Aeros"ace 3ngineering

re!% ?%6

06S3<.010

Introduction to the ATmega16

Atmel - 11

10-$ire 'um"er bet$een SEIT&L3S header and <D)TA header

.-$ire 'um"er bet$een )G CTG "ins of )S.?. S<A)3 and "ins < 0 and < 1 8res"ecti!ely9

10-$ire 'um"er bet$een 13 S header and <D)TA header #igure 1E, Connection o. E-pin jumper and 12-pin jumpers, The )G and TG "ins of the )S.?. S<A)3 header connect to "ins < 0 and < 1 res"ecti!ely using a t$o-$ire 'um"er% T$o 10-"in ribbon cable 'um"ers are used to connect the 10-"in SEIT&L3S header $ith the 10-"in <D)TA L3A 3), and to connect the 13 header $ith the <D)T# header% Ehen ma2ing all these connections, ma2e sure that the red stri"e connects to "in 1 at each header on both ends of the 'um"er%

Ac/no1ledgment Ee ac2no$ledge the generous su""ort of the Atmel &or"oration for "ro!iding A() Starter Kits, STK500 boards, and A() de!ices for use by the students and faculty of San =os> State +ni!ersity% Appendi> A D Installing *inA:" and A:" Studio The follo$ing "rocedure describes ho$ to install EinA() and A() Studio% Aor more hel" installing on your o"erating system, refer to $$$%a!rfrea2s%net% ,ote: default directories are usedJ ho$e!er, you may change them as desired as long as you ma2e necessary corrections $hen building "ro'ects, etc% Installing EinA() 1% o$nload the latest !ersion of EinA() from: htt":CCsourceforge%netC"ro'ectsC$ina!r .% Install EinA() by double-clic2ing the self e*tracting installation "rogram: *inA:"-versioninstall,e>e 8$here !ersion is the current !ersion number9 ?% Acce"t the default choices unless you ha!e good reasons to do other$ise 6% After installation the )3A 43 file $ill o"en in your bro$ser $indo$% )ead this7 Installing A() Studio 1% o$nload the latest !ersion of A() Studio 8free registration reHuired9 and the latest Ser!ice <ac2 8if any9 from: htt":CC$$$%atmel%comCdynC"roductsCtoolsPcard%as"XtoolPidY.T.5

San =os> State +ni!ersity e"t% of 4echanical and Aeros"ace 3ngineering

re!% ?%6

06S3<.010

Introduction to the ATmega16

Atmel - 1.

.% ?%

ouble clic2 on the installation file% uring installation, 2ee" all the default o"tions and "rogram locations% If during the installation A() Studio as2s if you $ant to install the =ungo +S# ri!er, chec2 that you $ant to install it% This $ill enable you to use +S#-based A() "rogrammers such as the A()IS< m2II and the A() ragon%

&ongratulations7 ;ou are ready to start "rogramming the ATmega16 using EinA() and A() Studio% Appendi> D +andling IS' Mode !rror

If you try to "rogram a brand-ne$ ATmega16 microcontroller, you may get a dialog bo* titled, /IS< 4ode 3rror0 $ith some !erbiage li2e, /A "roblem occurredQ0, such as sho$n in Aigure #1% ;ou may get the same dialog bo* if you neglected to connect the )S.?. cable or the 6-"in ribbon cable for IS< "rogramming%

#igure 1, IS' Mode !rror, ;ou may get this error trying to "rogram a brand-ne$ Atmega microcontroller or if the )S.?. cable or IS< "rogramming cable are not connected "ro"erly%

If you get this error, first chec2 that the )S.?. cable and the IS< "rogramming cable are both connected "ro"erly% If the error continues after you ha!e !erified that the cables are connected "ro"erly, and re-tried to do$nload your "rogram, you may need to tem"orarily ad'ust the IS< "rogramming freHuency% To do this: 1% &lic2 the &onnect icon to get the "rogramming dialog bo* o"en .% Fo to the 4ain tab, and under the /<rogramming 4ode and Target Settings section, clic2 on the Settings button, and set the IS< freHuency to 5T%6 2L@ as sho$n in Aigure #.% ?% &lic2 on the Erite button, then clic2 on the &lose button% 6% )eturn to the Auses tab, and set the chec2bo*es and "ull-do$n selections as s"ecified in the instructions earlier, then clic2, B<rogram: to burn the fuses% (erify that the fuses ha!e been set "ro"erly 8all lines in the log $indo$ should end $ith, BDK7:9% 5% )eturn to the 4ain tab, and set the IS< freHuency bac2 to 1%O65 4L@, clic2 on the Erite button, then clic2 on the &lose button% ;ou should be good to go no$7

San =os> State +ni!ersity e"t% of 4echanical and Aeros"ace 3ngineering

re!% ?%6

06S3<.010

Introduction to the ATmega16

Atmel - 1?

#igure 1, Temporaril0 changing the IS' .reAuenc0, Sometimes $ith a brand-ne$ microcontroller it is necessary to go to a slo$er "rogramming freHuency, so that the fuses can be set "ro"erly% Try 5T%6 2L@% After you "rogram the fuses, you should change the freHuency bac2 to 1%O65 4L@ before going on to "rogram your microcontroller%

San =os> State +ni!ersity e"t% of 4echanical and Aeros"ace 3ngineering

re!% ?%6

06S3<.010

You might also like