Anda di halaman 1dari 33

CDevelopmentEnvironmentfortheAVR

WhyusingC? Cisahigh g levelp programming g glanguage: g g Ccodeiseasiertounderstand comparedtootherlanguages. Csupports pp lowlevelp programming: g g WecanuseCtoaccessall hardwarecomponentsofthemicrocontroller. Chasstandardlibrariesforcomplex p tasks:datatype yp conversions, , standardinput/output,longintegerarithmetic. TheAtmelAVRinstructionsetisdesigned g tosupport pp Ccompilers: p C codecanbeconvertedefficientlytoassemblycode.

C TOOLS
WeneedtwotoolsforCdevelopment:AtmelAVRStudioand WinAVR. AtmelAVRStudio AnintegrateddevelopmentenvironmentforAtmelAVR microcontroller. Itincludes i l d editor, di assembler, bl emulator, l HEXfile fil d downloader. l d Availableat:www.atmel.com/tools/studioarchive.aspx ACcompilerforAVRmicrocontrollers. Canbeusedalone,orasap plug ginforAtmelAVRStudio. Availableat:winavr.sourceforge.net

WinAVR

Installing C tools
Usethefollowingversions: *AtmelAVRStudioversion4.18build692 *WinAVRrelease2010 2010.01.10 01 10
1)DownloadsetupfilesforAtmelAVRStudioandWinAVR

http://www.elec.uow.edu.au/avr/getdoc.php?doc=tools/AvrStud i 4S t io4Setup.exe http://www.elec.uow.edu.au/avr/getdoc.php?doc=tools/AVRStu dio4.18SP1.exe http://www.elec.uow.edu.au/avr/getdoc.php?doc=tools/WinAVR 20100110install.exe

2)RunsetupfileforAtmelAVRStudio. Studio Acceptdefaultoptions. options 2)RunsetupfileforWinAVR.Acceptdefaultoptions.

Development cycle for C


Step1:Createwinavrproject projectname

Step2:EnteraCprogram. Step3:CreateaMakefile Step4:Compile il the h Cprogramtoproduce d aHEXfil file. Step5:DownloadandtesttheHEXfileonAtmelAVRmicrocontroller.

Review of C programming
Step1:Createwinavrproject projectname StructureofaCprogram typesandoperators DataFlow l control lin i C Cfunctions Here,areviewofaspectsoftheCprogramminglanguage.

Structure of C program

C comments

Statement and Blocks

Data types and operators

C operators

Arithmetic Operators

Relational operators

Logical operators

Bit wise operators

Data access operators

Miscellaneous operators

Flow control in c

If-else statement

Switch Statement

While statement

For statement

do statement

Break statement in loop

Continue statement

C arrays

Functions in C

Guidelines on c coding

DIO (Digital I/O) on Atmega16

DIO in Atmega16 - pins

DIO in Atmega16 configuring input/output

DIO in Atmega16 reading / writing

AVR header files

DIO in Atmega - programing

Anda mungkin juga menyukai