欢迎来到天天文库
浏览记录
ID:1671106
大小:475.50 KB
页数:31页
时间:2017-11-13
《数字硬件习题word版》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Tut07Q1-CDevelopmentEnvironmentStatethestepsandthetoolstodevelopaCprogramfortheAtmelAVRmicrocontroller.Step1:CreateAVRStudioproject:projectname;projecttypeC;selectsimulatoranddeviceStep2:EnteraCprogram.Step3:CompiletheCprogramtoproduceaHEXfile.Step4:DownloadandtestHEXfileonAtmelAVRmic
2、rocontroller.Tools:AtmelAVRStudioandWinAVRQ2-AtmelAVR-Specifics(a)WhatistheroleoftheheaderfileinaCprogramfortheAtmelAVR?(1)Dependingonwhatdeviceselectedfortheproject,willredirecttoaspecificheaderfile.(2)ThespecificheaderfilecontainstheCdefinitionsforallregistersoft
3、heAVRmicrocontroller.(3)ForATmega16,thespecificheaderfileis(seeLabNotesAppendixA).b)WriteaCcodeexamplethatusesinlineassemblycoding.(1)Wecanuse__asm__directive.(2)Forexample,tocreateadelayusingassemblyinstructionnop:__asm____volatile__("nop");(3)The__volatile__directiveforcest
4、heCcompilertokeeptheorderofCinstructions.Thatis,nocodeoptimizationisperformed.Q3-CLanguageElementsa)NametheCkeywordthatcanbeusedtoquitafunctionimmediately.return;b)NametheCkeywordthatcanbeusedtoterminatealoopimmediately.break;c)NametheCkeywordthatcanbeusedtoforcethenextiterationofaloo
5、ptostartimmediately.continue;d)Statetherolesofthekeywords'break'and'default'intheC'switch-case'construct.(1)Keyword'break'isusedtoterminatetheC'switch-case'constructafteracasehasbeenhandled.(2)Keyword'default'isusedtospecifytheinstructionstorunwhennocaseismatched.switch(a)case'0':PORT
6、B=0b00111111;break;…case'9':PORTB=0b01101111;break;default:PORTB=0b00000000;e)DifferentiatebetweenthetwoCoperators&and&&.(1)&isbit-wiseoperatorforAND,usedonanyintegerdatatype.(2)&&islogicaloperatorforAND,usedwithlogicaldatatypesandconditionalstatements.f)DifferentiatebetweenthetwoCope
7、rators~and!=.(1)~isbit-wiseoperatorforinversion,usedonanyintegerdatatype.(2)!=isacomparisonoperatorforNOTEQUAL,e.g.if(a!=b)(g)DifferentiatebetweenthetwoCoperators=and==.(1)=isassignmentoperator,e.g.PORTB=0b00111111(2)==isacomparisonoperatorforEQUAL,e.g.if(a==b)Q4)Bit-wiseOperatorsCons
8、idert
此文档下载收益归作者所有