introduction to keil-mdk-arm - sonoma state university · 2018. 2. 15. · device, file system, and...
TRANSCRIPT
-
IntroductiontoKeil-MDK-ARMUpdated:Thursday,February15,2018
-
Outline
• WhatareARMtools• WhatisKeil• WhatareKeil Components• InstallingKeil Lite• CreateanewprojectusingKeil• Steppingthroughasimpleassemblyprogram• Understandinganassemblyprogram
-
WhatisKeil MDK-ARM?
• Keil isaCortex-MDevelopmentplatform• Therearemanyotherplatforms
• MDK-ARMstandsforMicrocontrollerDevelopmentKitforARM• Keil’s latestversionis5:www2.keil.com/mdk5(watchthevideo)• TherearemanycomponentstoKeil MDK-ARM• uVision IntegratedDevelopmentEnvironment(IDE)• Compilationtools(C/C++)• Assembler• Linkunities(usedtoprogramthephysicaldevice)• Simulator(whennohardwareisavailable)• Etc.
AsidefromKeil therearemanyotheropensourceandcommercialtools:https://en.wikipedia.org/wiki/List_of_ARM_Cortex-M_development_tools
-
WhatisKeil MDK-ARM?
-
Keil MDK-ARMEditionsSeehttp://www.keil.com/mdk5/selector
• MDK-ProfessionalcontainsallfeaturesofMDK-Plus.Inaddition,itsupportsIPv4/IPv6dual-stacknetworking,IoT connectivity,andaUSBHoststack.Onceavailable,MDK-ProfessionalincludesARMv8-MarchitecturesupportandalicenseforDS-MDK.• MDK-PluscontainsmiddlewarelibrariesforIPv4networking,USBDevice,FileSystem,andGraphics.ItsupportsARMCortex-M,selectedARMCortex-R,ARM7,andARM9processorbasedmicrocontrollers.• MDK-Cortex-MsupportsCortex-Mprocessor-basedmicrocontrollers.• MDK-Lite iscodesizerestrictedto32KByte andintendedforproductevaluation,smallprojects,andtheeducationalmarket.
-
CompilationFlowinKeil
-
CortexMicrocontrollerSoftwareInterfaceStandard(CMSIS)• CMSISprovidestheinterfacebetweenthemicrocontrollerperipheralsandtheMDKMiddleware• ForourprojectsweneedtohaveCMSISCOREandDEVICESStartupfilesaddedtoourcode
-
InstallingKeil-1
• visitwww2.keil.com/mdk5/• DownloadMDK-Lite• Afterthedownloadhasfinished,doubleclickthe .exetoinstalltheprogram.• Once installed,clickfinish• Thepackinstallerwillload,andittakessometimeforittofindallthenewpackagesavailableforinstall.• Allowthepackinstallertofinishsearching(shownbytheactionbaratthebottomofthescreen)
visitwww2.keil.com/mdk5/
-
InstallingKeil - 2
• OntheleftsideofthewindowunderDevices,clicktoexpandSTMicroelectronics.
• Find STM32F4Seriesandexpandit
• DoubleclickonSTM32F401REanditshouldaddittothepackslistontherightside.
• ClickallthebuttonsthatsayInstallorUpdatetogetallthefeatures/packagesthatKeil offers.
-
StartANewProject• OpenKeil uVision 5fromyourWindows• Makesureallprojectsareclosed:
• Projectà CloseProject• ClickonProjectà newuVision Project…• InthewindowclickonNewFolder[1]• Typethenameoftheproject:ASM_NewProject [2]• Gotothenewfolderthatyoujustcreated[3]
[1]
[2]
[3]
-
StartANewProject-2• TheSelectDevicewindowpopsup• Inthesearchtype:STM32F401RETx• Clickonthedevice(STM32F401RETx)thatshowedupandthenclickOK
-
StartANewProject-3• AtthispointtheManageRunwindowpopsup• CHECKCMSISà COREandDEVICEàSTARTUPboxes–notethatthecolorchanges• ThenclickOK
IfDevicesAreMarkedasX
-
StartANewProject-4• AttispointyourProjectwindowshouldshowthe
CMSISandDEVICE– thesearetheCMSISsysteminitializationfilesandstartupfilesinorderfortheRUNTIMEtooperate [1]
• ClickontheOPTIONSFORTARGET[2]
• ClickonDEBUGtab[3]
• CHECKtheSIMULATOR[4]
• ClickonOK
• InthePROJECTwindowclickonSourceGroup1andselectADDNEWITEM….
• Inthenewwindowselect
[1]
[2][3][4]
-
StartANewProject-5• InthePROJECTwindowclickonSourceGroup1and
selectADDNEWITEM….
• InthenewwindowselectASMfiles
• ThentypethenameoftheASMfile:ASM_NewProject.s
• ClickonADD
-
StartANewProject-6• IntheprojectwindowclickonASM_NewProject.s
undertheSourceGroup1folder
• Openthefile
• Typeinthefollowingcode
• Savethefile
• PressF7andmakesuretherearenoerrors(asshownbelow)
• Clickonthedebugbutton– shownabove
• MakesuretherearenoerrorsandstepthroughthecodeasyouclickontheSTEPINbuttonshownabove
***UsingCompiler'V5.06update5(build528)',folder:'C:\Keil_v5\ARM\ARMCC\Bin'Build target'Target1'assemblingchange_register.s...linking...ProgramSize:Code=188RO-data=404RW-data=0ZI-data=1536".\Objects\NewProject.axf"- 0Error(s),0Warning(s).BuildTimeElapsed:00:00:00
-
StartANewProject-7• Setupyourprojectwindowsareshownbelow
• Todoso,clickonVIEWandselecttheappropriatewindow
FILESAssembly&Startup)
Disassembler
REGISTERS
PROJECT
MEMORYCOMMAND
-
Let’sExamineTheCode• Whatarethevaluesoftheregistersafteryoustepthroughtheentirecode?• WhatisthevalueofP?• Whathappensifwechange#PtoPandremove#?• IntheDisassemblernotehowthecodesaredisplayed.Whatisthestartingmemorylocationfortheassemblycode?
• WhatistheOPCODEforMOVinstruction?• WhatistheOPCODEforADDinstruction?• Howlarge(intermsofbits)isregisterR0?• Whatexactlythefollowingcommandachieves?ADDr2,r0,r1
-
Example1:Addition
-
DoThis:
• Trythefollowingandshowthevaluesoftheregistersaftertheprogramiscompleted:
MOVr1,#Q;loadQintor1MOVr2,#R;loadRintor2MOVr3,#S;loadSintor3ADDr0,r1,r2;AddQtoRADDr0,r0,r3;AddSto(Q+R)
-
References
• TheDefinitiveGuidetoARM®Cortex®-M3andCortex®-M4Processors– Chapter15
-
IfYouExperienceAnyIssues….
-
PotentialIssues
IfYouHavethiserror
-
IfYouGetCompilingIssue• AttispointyourProjectwindowshouldshowthe
CMSISandDEVICE– thesearetheCMSISsysteminitializationfilesandstartupfilesinorderfortheRUNTIMEtooperate [1]
• ClickontheOPTIONSFORTARGET[2]
• ClickonDEBUGtab[3]
• CHECKtheSIMULATOR[4]
• ClickonOK
• InthePROJECTwindowclickonSourceGroup1andselectADDNEWITEM….
• Inthenewwindowselect
[1]
[2][3][4]
-
IfDevicesAreMarkedasXRe-dothissection