毕业设计外文翻译Word文件下载.docx
《毕业设计外文翻译Word文件下载.docx》由会员分享,可在线阅读,更多相关《毕业设计外文翻译Word文件下载.docx(23页珍藏版)》请在冰点文库上搜索。
![毕业设计外文翻译Word文件下载.docx](https://file1.bingdoc.com/fileroot1/2023-5/1/caba9ae1-e3b1-4bfb-80a5-6b31b33e369a/caba9ae1-e3b1-4bfb-80a5-6b31b33e369a1.gif)
TheMSP430familyisabroadfamilyoflowpower,featurerich16-bitmicrocontrollersfromTexasInstruments.Theyshareacommon,RISC-type,NeumannCPUcore.The'
430iscompetitiveinpricewiththe8-bitcontrollermarket,andsupportsboth8and16-bitinstructions,allowingmigrationfrommostsimilarlysizedplatforms.
Thefamilyofdevicesrangesfromtheverysmall(1kROM,128bytesforRAM,sub-dollar)uptolarger(60kROM,2kRAM,withpricesinthe$10range)devices.Currently,thereareatleast40flavorsavailable,withmorebeingaddedregularly.Thedevicesaresplitintothreefamilies:
theMSP430x3xx,whichisabasicunit,theMSP430x1xx,whichisamorefeature-richfamily,andtheMSP430x4xx,whichissimilartothe'
1xx,withabuiltinLCDdriver.Youwillfindthesereferredtoas'
1xx,'
3xx,and'
4xxdevicesthroughoutthisbook.
PartNumberingConvention
PartnumbersforMSP430devicesaredeterminedbasedontheircapabilities.Alldevicepartnumbersfollowthefollowingtemplate:
MSP430MtFaFbMc
M:
MemoryType
C:
ROM
F:
Flash
P:
OTP
E:
EPROM(fordevelopmentaluse.Therearefewofthese.)
Fa,Fb:
FamilyandFeatures
10,11:
Basic
12,13:
HardwareUART
14:
HardwareUART,HardwareMultiplier
31,32:
LCDController
33:
LCDController,HardwareUART,HardwareMultiplier
41:
43:
LCDController,HardwareUART
44:
Mc:
MemoryCapacity
0:
1kbROM,128bRAM
1:
2kbROM,128bRAM
2:
4kbROM,256bRAM
3:
8kbROM,256bRAM
4:
12kbROM,512bRAM
5:
16kbROM,512bRAM
6:
24kbROM,1kbRAM
7:
32kbROM,1kbRAM
8:
48kbROM,2kbRAM
9:
60kbROM,2kbRAM
Example:
TheMSP430F435isaFlashmemorydevicewithanLCDcontroller,ahardwareUART,16kbofcodememory,and512bytesofRAM.
Thepartnumberingschemedescribedaboveisabitfragmented.Therearecommonfeaturesnotconsistentlyrepresented(typeofADC,numberoftimers,etc),andtherearesomeotherinconsistencies(forexample,the33familyhasthemultiplier,butthe13and43sdonot).Iwouldrecommendagainstselectingpartsbasedontheirnumberingscheme.Rather,onceyouhaveavagueideaofyourrequirements,gototheTIwebsite(www.TI.com),andusetheirparametricsortfeature.
Architecture:
CPUandMemory
Asdiscussedinchapter1,theMSP430utilizesa16-bitRISCarchitecture,whichiscapableofprocessinginstructionsoneitherbytesorwords.TheCPUisidenticalforallmembersofthe'
430family.Itconsistsofa3-stageinstructionpipeline,instructiondecoding,a16-bitALU,fourdedicated-useregisters,andtwelveworking(orscratchpad)registers.TheCPUisconnectedtoitsmemorythroughtwo16-bitbusses,oneforaddressing,andtheotherfordata.Allmemory,includingRAM,ROM,informationmemory,specialfunctionregisters,andperipheralregistersaremappedintoasingle,contiguousaddressspace.
Thisarchitectureisuniqueforseveralreasons.First,thedesignersatTexasInstrumentshaveleftanawfullotofspaceforfuturedevelopment.AlmosthalftheStatusRegisterremainsavailableforfuturegrowth,roughlyhalfoftheperipheralregisterspaceisunused,andonlysixofthesixteenavailablespecialfunctionregistersareimplemented.
Second,thereareplentyofworkingregisters.Afteryearsofhavingoneortwoworkingregisters,Igreatlyenjoyedmyfirstexperiencewiththetwelve16-bitCPUscratchpads.Theprogrammingstyleisslightlydifferent,andcanbemuchmoreefficient,especiallyinthehandsofaprogrammerwhoknowshowtousethisfeaturetoitsfullest.
Third,thisarchitectureisdeceptivelystraightforward.Itisveryflexible,andtheaddressingmodesaremorecomplicatedthanmostothersmallprocessors.But,beyondthat,thisarchitectureissimple,efficientandclean.Therearetwobusses,asinglelinearmemoryspace,arathervanillaprocessorcore,andallperipheralsarememory-mapped.
CPUFeatures
TheALU
The'
430processorincludesaprettytypicalALU(arithmeticlogicunit).TheALUhandlesaddition,subtraction,comparisonandlogical(AND,OR,XOR)operations.ALUoperationscanaffecttheoverflow,zero,negative,andcarryflags.Thehardwaremultiplier,whichisnotavailableinalldevices,isimplementedasaperipheraldevice,andisnotpartoftheALU(seeChapter6).
WorkingRegisters
430givesthedevelopertwelve16-bitworkingregisters,R4throughR15.(R0throughR3areusedforotherfunctions,asdescribedlater.)Theyareusedforregistermodeoperations(seeAddressingModes,Chapter8),whicharemuchmoreefficientthanoperationswhichrequirememoryaccess.Someguidelinesfortheiruse:
Usetheseregistersasmuchaspossible.Anyvariablewhichisaccessedoftenshouldresideinoneoftheselocations,forthesakeofefficiency.
Generallyspeaking,youmayselectanyoftheseregistersforanypurpose,eitherdataoraddress.However,somedevelopmenttoolswillreserveR4andR5fordebuginformation.Differentcompilerswillusetheseregistersindifferentfashions,aswell.Understandyourtools.
Beconsistentaboutuseoftheworkingregisters.Clearlydocumenttheiruse.Ihavecode,writtenabout8monthsago,thatperformsextensiveoperationsonR8,R9,andR15.Unfortunately,Idon'
tknowtodaywhatthevaluesinR8,R9andR15represent.ThiswascodeIwrotetoquicklyvalidateanalgorithm,ratherthanproductioncode,soIdidn'
tdocumentitsufficiently.Now,itisrelativegibberish.Don'
tletthishappentoyou.Nomatterhowobviousortrivialregisteruseseems,documentitanyway.
ConstantGenerators
R2andR3functionasconstantgenerators,sothatregistermodemaybeusedinsteadofimmediatemodeforsomecommonconstants.(R2isadualuseregister.ItservesastheStatusRegister,aswell.)Generatedconstantsincludesomecommonsingle-bitvalues(0001h,0002h,0004h,and0008h),zero(0000h),andanall1sfield(0FFFFh).GenerationisbasedontheW(S)valueintheinstructionword,andisdescribedbythetablebelow.
W(S)valueinR2valueinR3
00————0000h
01(0)(absolutemode)0001h
100004h0002h
110008h0FFFFh
ProgramCounter
TheProgramCounterislocatedinR0.Sinceindividualmemorylocationaddressesare8-bit,butallinstructionsare16bit,thePCisconstrainedtoevennumbers(i.e.theLSBofthePCisalwayszero).Generallyspeaking,itisbesttoavoiddirectmanipulationofthePC.Oneexceptiontothisruleofthumbistheimplementationofaswitch,wherethecodejumpstoaspot,dependentonagivenvalue.(I.e.,ifvalue=0,jumptolocation0,ifvalue=1,jumptolocation1,etc.)ThisprocessisshowninExample3.1.
Example3.1SwitchStatementviaManualPCControl
Movvalue,R15;
puttheswitchvalueintoR15
CmpR15,#8;
rangechecking
Jgeoutofrange;
ifR15>
7,donotusePCswitch
Cmp#0,R15;
morerangechecking
Jnoutofrange;
RlaR15;
multiplyR15bytwo,sincePCisalwayseven
doubleR15again,sincesymbolicjmpis2wordslong
AddR15,PC;
PCgoestoproperjump
Jmpvalue0
Jmpvalue1
Jmpvalue2
Jmpvalue3
Jmpvalue4
Jmpvalue5
Jmpvalue6
Jmpvalue7
Outofrange
JmpRangeError
Thisisarelativelycommonapproach,andmostCcompilerswillimplementswitchstatementswithsomethingsimilar.Whenimplementingthismanually(i.e.,inassemblylanguage),theprogrammerneedstokeepseveralthingsinmind:
Alwaysdoproperrangechecking.Intheexample,wecheckedforconditionsoutsidebothendsofthevalidrange.Ifthisisnotperformedcorrectly,thecodecanjumptoanunintendedlocation.
Paycloseattentiontotheaddressingmodesofthejumpstatements.TheseconddoublingofR15,priortotheaddstatement,isaddedbecausethejumpstatementrequirestwowordswhensymbolicmodeaddressingisused.
Becarefulthatnoneofyourinterrupthandlershavethepotentialtoaffectyourvalueregister(R15intheexample).Iftheinterrupthandlerneedstouseoneoftheseregisters,thehandlerneedstostorethevaluetoRAMfirst.ThemostcommonprocedureistopushtheregistertothestackatthebeginningoftheISR,andtopoptheregisterattheendoftheISR.(SeeExample3.2.)
Example3.2Push/PopCombinationinISR
Timer_A_Hi_Interrupt
PushR12;
WewilluseR12
MovP1IN,R12;
useR12asweplease
RlaR12
RlaR12
MovR12&
BAR;
DonewithR12
PopR12;
RestorepreviousvaluetoR12
Reti;
returnfrominterrupt
ORG0FFF0h
DWTimer_A_Hi_Interrupt
StatusRegister
TheStatusRegisterisimplementedinR2,andiscomprisedofvarioussystemflags.Theflagsarealldirectlyaccessiblebycode,an