You are on page 1of 5

SanJosStateUniversity

CollegeofEngineering/ElectricalEngineering

EE138,IntroductiontoEmbeddedControlSystemDesign
Section01,Spring2014

ProfessorPingHsu

Engineering403

LabRoom:
AtmelAVRStudio6.2orlatest

Lecturer:
LectureRoom:
Engineering244

SoftwareTools:

References:

DatasheetsandApplicationNotes(providedonline)
http://www.atmel.com/Images/Atmel42102SAMD20XplainedPro_UserGuide.pdf
(SAMD20data
sheet)
http://www.elec.uow.edu.au/avr/index.php
(oldAVRcode)
http://www.avrfreaks.net/
(AVR/atmelforum)
http://www.csee.umbc.edu/portal/help/C++/summary.shtml
(basicC++code)

Acknowledgements:
ProfessorChristopherPham
TravisJohnson
AlanChen
JonathanTran

TentativeLabSchedule:

Lab#

LabTopic

TimePeriod

GeneralPurposeInput/Output(GPIO)

1/27/152/17/15

AnalogInterface(ADC)

2/17/153/3/15

PulseWidthModulation(PWM)

67thweek

Interrupts

811thweek

SerialCommunication

1214thweek

GettingtoKnowtheAtmelStudio

Introduction

TutorialforNewProject:
1. OpenAtmelStudio.
2. Clickonfile
a. GotoNew>Project(showninFigure1.)
3. ClickonGCCCASFBoardProjectC/C++(showninFigure2.)
a. Nameitwhateveryouwouldlike(showninFigure3)
b. SelectthelocationyouwouldliketheprojecttobelocatedbyclickingontheBrowsebutton
c. Clickok
4. BoardSelectionwindowwillappear(showninFigure4.)
a. ClickontheDeviceFamilytoselectSAMD(showninFigure5.)
b. Find
ATSAMD20J18
inthelist(showninFigure6.)
c. Oncethatisclickedontwooptionswillappearatthebottomofthescreen.selecttheUser
Boardtemplate
ATSAMD20j18
(showninFigure7.)
d. Clickok
5. AtmelStudiowillthencreateandloadinthenewproject
6. IntheSolutionExplorerwindowfindthesrcfileandexpandit(showninFigure8.)
a. Openthemain.cfile
b. Thisisthefilethatyouwillcodein.(showninFigure9.)

PreloadedCode:
7. Therearetwolinesofcodealreadyincludedintothemain.cfile.
a. #include<asf.h>
i.
Thislineofcodeincludesalloftheheaderfilesthatincludedefinitionsforvariables
andfunctionsthatcanbeusedbytheuser.
b. system_init()
i.
Thislineofcodeincludesfourfunctions.Thesefunctionsareweakandcan
thereforebeoverwrittenwithotherfunctions.
1. system_clock_init()
a. Thisfunctionsetsuptheinternalclocktoadefault8MHzaswell
assetupallthegenericclockstodefaultstates.Inlaterlabsyou
willneedtochangethegenericclockssettings.
2. system_board_init()
a. Thisfunctionisemptyandcanbeusedasaplacetoinitializeallof
yourI/Opins.Howeverforlabwewillbedoingeverythinginthe
main.cfile
3. _system_events_init()
and
_system_extint_init()
a. Bothofthesefunctionsaresimilartothesystem_board_init()
functioninwhichtheyarejustplaceholdersforcodethatyoucould
writeinto.Howeverwewillbeusingthemain.cfiletoputall
neededinitializationsandotherneededfunctions


Figure1.New>Project

Figure2.SelectGCCCASFBoardProject

Figure3.Nameyourproject


Figure4.Windowthatpopsupafterpressingokonfigure3

Figure5.SelecttheSAMDindevicefamily

Figure6.SelectATSAMD20J18

Figure7.SelectingtheUserBoardtemplate

Figure8.ExpandthesrcfolderintheSolutionExplorerwindow

Figure9.Themain.cisthefilethatyourcodewillbewrittenin

You might also like