loading

Logout succeed

Logout succeed. See you again!

ebook img

MSP430 Microcontroller Basics PDF

pages685 Pages
release year2008
file size4.06 MB
languageEnglish

Preview MSP430 Microcontroller Basics

MSP430 Microcontroller Basics Thispageintentionallyleftblank MSP430 Microcontroller Basics John H. Davies AMSTERDAM•BOSTON•HEIDELBERG•LONDON NEWYORK•OXFORD•PARIS•SANDIEGO SANFRANCISCO•SINGAPORE•SYDNEY•TOKYO NewnesisanimprintofElsevier NewnesisanimprintofElsevier 30CorporateDrive,Suite400,Burlington,MA01803,USA LinacreHouse,JordanHill,OxfordOX28DP,UK Copyright©2008,ElsevierLtd.Allrightsreserved. Nopartofthispublicationmaybereproduced,storedinaretrievalsystem,ortransmittedinanyform orbyanymeans,electronic,mechanical,photocopying,recording,orotherwise,withouttheprior writtenpermissionofthepublisher. PermissionsmaybesoughtdirectlyfromElsevier’sScience&TechnologyRightsDepartmentinOxford, UK:phone:(+44)1865843830,fax:(+44)1865853333,E-mail:[email protected] alsocompleteyourrequestonlineviatheElsevierhomepage(http://www.elsevier.com)byselecting “Support&Contact”then“CopyrightandPermission”andthen“ObtainingPermissions.” Recognizingtheimportanceofpreservingwhathasbeenwritten,Elsevierprintsits booksonacid-freepaperwheneverpossible. LibraryofCongressCataloging-in-PublicationData Applicationsubmitted BritishLibraryCataloguing-in-PublicationData AcataloguerecordforthisbookisavailablefromtheBritishLibrary. ISBN:978-0-7506-8276-3 ForinformationonallNewnespublications, visitourWebsiteat:http://www.books.elsevier.com 08 09 10 11 12 13 10 9 8 7 6 5 4 3 2 1 PrintedintheUnitedStatesofAmerica “ToElizabeth.” Thispageintentionallyleftblank Contents Preface........................................................................... xi Chapter1:EmbeddedElectronicSystemsandMicrocontrollers ................... 1 1.1 What(andWhere)AreEmbeddedSystems? .................................... 1 1.2 ApproachestoEmbeddedSystems............................................... 2 1.3 SmallMicrocontrollers ........................................................... 5 1.4 AnatomyofaTypicalSmallMicrocontroller.................................... 8 1.5 Memory........................................................................... 11 1.6 Software..........................................................................15 1.7 WhereDoestheMSP430Fit?...................................................16 Chapter2:TheTexasInstrumentsMSP430 .....................................21 2.1 TheOutsideView—Pin-Out ....................................................21 2.2 TheInsideView—FunctionalBlockDiagram..................................24 2.3 Memory...........................................................................25 2.4 CentralProcessingUnit..........................................................30 2.5 Memory-MappedInputandOutput.............................................32 2.6 ClockGenerator..................................................................33 2.7 Exceptions:InterruptsandResets...............................................36 2.8 WheretoFindFurtherInformation .............................................37 Chapter3:Development.........................................................43 3.1 DevelopmentEnvironment......................................................44 3.2 TheCProgrammingLanguage..................................................46 3.3 AssemblyLanguage..............................................................55 3.4 AccesstotheMicrocontrollerforProgrammingandDebugging..............57 3.5 DemonstrationBoards...........................................................59 3.6 Hardware .........................................................................64 3.7 Equipment........................................................................65 www.newnespress.com viii Contents Chapter4:ASimpleTouroftheMSP430.......................................67 4.1 FirstProgramonaConventionalDesktopComputer..........................68 4.2 LightLEDsinC .................................................................70 4.3 LightLEDsinAssemblyLanguage.............................................72 4.4 ReadInputfromaSwitch .......................................................80 4.5 AutomaticControl:FlashingLightbySoftwareDelay ........................91 4.6 AutomaticControl:UseofSubroutines.........................................99 4.7 AutomaticControl:FlashingLightbyPollingTimer_A......................105 4.8 HeaderFilesandIssuesBrushedundertheCarpet............................114 Chapter5:ArchitectureoftheMSP430Processor .............................119 5.1 CentralProcessingUnit.........................................................119 5.2 AddressingModes ..............................................................125 5.3 ConstantGeneratorandEmulatedInstructions................................131 5.4 InstructionSet...................................................................132 5.5 Examples ........................................................................146 5.6 ReflectionsontheCPUandInstructionSet ...................................153 5.7 Resets............................................................................157 5.8 ClockSystem....................................................................163 Chapter6:Functions,Interrupts,andLow-PowerModes .......................177 6.1 FunctionsandSubroutines .....................................................178 6.2 WhatHappenswhenaSubroutineIsCalled? .................................178 6.3 StorageforLocalVariables.....................................................179 6.4 PassingParameterstoaSubroutineandReturningaResult..................183 6.5 MixingCandAssemblyLanguage ............................................185 6.6 Interrupts ........................................................................186 6.7 WhatHappenswhenanInterruptIsRequested? ..............................188 6.8 InterruptServiceRoutines......................................................190 6.9 IssuesAssociatedwithInterrupts...............................................196 6.10 Low-PowerModesofOperation...............................................198 Chapter7:DigitalInput,Output,andDisplays.................................207 7.1 DigitalInputandOutput:ParallelPorts .......................................208 7.2 DigitalInputs....................................................................216 7.3 SwitchDebounce ...............................................................225 7.4 DigitalOutputs..................................................................238 7.5 Interfacebetween3Vand5VSystems.........................................243 7.6 DrivingHeavierLoads..........................................................247 7.7 LiquidCrystalDisplays.........................................................252 7.8 DrivinganLCDfromanMSP430x4xx........................................256 7.9 SimpleApplicationsoftheLCD ...............................................264 www.newnespress.com Contents ix Chapter8:Timers..............................................................275 8.1 WatchdogTimer.................................................................276 8.2 BasicTimer1 ....................................................................281 8.3 Timer_A.........................................................................287 8.4 MeasurementintheCaptureMode ............................................300 8.5 OutputintheContinuousMode................................................318 8.6 OutputintheUpMode:Edge-AlignedPulse-WidthModulation ............330 8.7 OutputintheUp/DownMode:CenteredPulse-WidthModulation ..........349 8.8 OperationofTimer_AintheSamplingMode.................................352 8.9 Timer_B .........................................................................353 8.10 WhatTimerWhere?.............................................................356 8.11 SettingtheReal-TimeClock:StateMachines.................................357 Chapter9:Mixed-SignalSystems:AnalogInputandOutput....................369 9.1 Comparator_A...................................................................371 9.2 Analog-to-DigitalConversion:GeneralIssues ................................393 9.3 Analog-to-DigitalConversion:SuccessiveApproximation...................402 9.4 TheADC10Successive-ApproximationADC.................................407 9.5 BasicOperationoftheADC10.................................................412 9.6 MoreAdvancedOperationoftheADC10 .....................................424 9.7 TheADC12Successive-ApproximationADC.................................432 9.8 Analog-to-DigitalConversion:Sigma–Delta..................................438 9.9 TheSD16_ASigma–DeltaADC...............................................446 9.10 OperationofSD16_A...........................................................459 9.11 SignalConditioningandOperationalAmplifiers..............................475 9.12 Digital-to-AnalogConversion..................................................485 Chapter10:Communication....................................................493 10.1 CommunicationPeripheralsintheMSP430...................................495 10.2 SerialPeripheralInterface......................................................497 10.3 SPIwiththeUSI ................................................................504 10.4 SPIwiththeUSCI ..............................................................513 10.5 AThermometerUsingSPIinMode3withtheF2013asMaster.............520 10.6 AThermometerUsingSPIinMode0withtheFG4618asMaster...........526 10.7 Inter-integratedCircuitBus ....................................................534 10.8 ASimpleI²CMasterwiththeUSCI_B0onaFG4618........................542 10.9 ASimpleI²CSlavewiththeUSIonaF2013..................................549 10.10 StateMachinesforI²CCommunication .......................................559 10.11 AThermometerUsingI²CwiththeF2013asMaster .........................567 10.12 AsynchronousSerialCommunication .........................................574 10.13 AsynchronousCommunicationwiththeUSCI_A.............................581 www.newnespress.com

See more

The list of books you might like