用于MSP430的Code
Composer
Studio用户指南v6.1
用于
MSP430
Code
Studio
用户指南
v6
Code Composer Studio v6.1 for MSP430Users GuideLiterature Number:SLAU157AIMay 2005Revised June 2015ContentsPreface.61Get Started Now!.91.1Software Installation.101.2Flashing the LED.101.3Important MSP430 Documents on the DVD and Web.112Development Flow.132.1Using Code Composer Studio IDE(CCS).142.1.1Creating a Project From Scratch.142.1.2Project Settings.152.1.3Using Math Library for MSP430(MSPMathlib)in CCS v5.5 and Newer.152.1.4Using an Existing CCE v2,CCE v3,CCE v3.1,CCS v4.x,or CCS v5.x Project.152.1.5Stack Management.162.1.6How to Generate Binary Format Files(TI-TXT and INTEL-HEX).162.2Using the Integrated Debugger.162.2.1Breakpoint Types.162.2.2Using Breakpoints.193EnergyTrace Technology.233.1Introduction.233.2Energy Measurement.233.3Code Composer Studio Integration.233.3.1EnergyTrace Technology Settings.243.3.2Controlling EnergyTrace Technology.283.3.3EnergyTrace+Mode.293.3.4EnergyTrace Mode.343.3.5Comparing Captured Data With Reference Data.373.4EnergyTrace Technology FAQs.384Memory Protection Unit and Intellectual Property Encapsulation.424.1Memory Protection Unit(MPU).424.2Intellectual Property Encapsulation(IPE).434.2.1IPE Debug Settings.44AFrequently Asked Questions.46A.1Hardware.47A.2Program Development(Assembler,C-Compiler,Linker,IDE).47A.3Debugging.48BMigration of C Code from IAR 2.x,3.x,or 4.x to CCS.52B.1Interrupt Vector Definition.53B.2Intrinsic Functions.53B.3Data and Function Placement.53B.3.1Data Placement at an Absolute Location.53B.3.2Data Placement Into Named Segments.54B.3.3Function Placement Into Named Segments.54B.4C Calling Conventions.55B.5Other Differences.55B.5.1Initializing Static and Global Variables.552ContentsSLAU157AIMay 2005Revised June 2015Submit Documentation FeedbackCopyright 20052015,Texas Instruments IB.5.2Custom Boot Routine.56B.5.3Predefined Memory Segment Names.56B.5.4Predefined Macro Names.57CMigration of Assembler Code from IAR 2.x,3.x,or 4.x to CCS.59C.1Sharing C/C+Header Files With Assembly Source.60C.2Segment Control.60C.3Translating A430 Assembler Directives to Asm430 Directives.61C.3.1Introduction.61C.3.2Character Strings.61C.3.3Section Control Directives.62C.3.4Constant Initialization Directives.62C.3.5Listing Control Directives.62C.3.6File Reference Directives.63C.3.7Conditional Assembly Directives.64C.3.8Symbol Control Directives.64C.3.9Macro Directives.65C.3.10Miscellaneous Directives.65C.3.11Alphabetical Listing and Cross Reference of Asm430 Directives.66C.3.12Unsupported A430 Directives(IAR).67DWriting Portable C Code for CCS and Red Hat GCC for MSP430.69D.1Interrupt Vector Definition.70EFET-Specific Menus.72E.1Menus.73E.1.1Debug View:Run Free Run.73E.1.2Run Connect Target.73E.1.3Run Advanced Make Device Secure.73E.1.4Project Properties Debug MSP430 Properties Clock Control.73E.1.5Window Show View Breakpoints.73E.1.6Window Show View Other.Debug Trace Control.73E.1.7Project Properties Debug MSP430 Properties Target Voltage.73FDevice Specific Menus.75F.1MSP430L092.75F.1.1Emulation Modes.75F.1.2Loader Code.77F.1.3C092 Password Protection.78F.2MSP430F5xx and MSP430F6xx BSL Support.79F.3MSP430FR5xx and MSP430FR6xx Password Protection.80F.4MSP430 Ultra-Low-Power LPMx.5 Mode.81F.4.1What is LPMx.5.81F.4.2Debugging LPMx.5 Mode on MSP430 Devices That Support the Ultra-Low-Power Debug Mode.81F.4.3Debugging LPMx.5 Mode on MSP430 Devices That Do Not Support the Ultra-Low-Power DebugMode.83Revision History.853SLAU157AIMay 2005Revised June 2015ContentsSubmit Documentation FeedbackCopyright 20052015,Texas Instruments IList of Figures2-1.Breakpoints.192-2.Breakpoint Properties.203-1.Pulse Density and Current Flow.233-2.EnergyTrace Button in the Toolbar Menu.243-3.Exit EnergyTrace Mode.243-4.EnergyTrace Technology Preferences.253-5.Project Properties.263-6.Debug Properties.273-7.Battery Selection.283-8.Custom Battery Type.283-9.Target Connection.283-10.EnergyTrace Technology Control Bar.293-11.Debug Session With EnergyTrace+Graphs.303-12.Profile Window.313-13.States Window.323-14.Power Window.333-15.Energy Window.333-16.Debug Session With EnergyTrace Graphs.343-17.EnergyTrace Profile Window.353-18.Zoom Into Power Window.353-19.Zoom Into Energy Window.363-20.Energy Profile of the Same Program in Resume(Yellow Line)and Free Run(Green Line).363-21.Comparing Profiles in EnergyTrace+Mode.373-22.Comparing Profiles in EnergyTrace Mode.384-1.MPU Configuration Dialog.424-2.IPE Configuration Dialog.434-3.IPE Debug Settings.44F-1.MSP430L092 Modes.76F-2.MSP430L092 in C092 Emulation Mode.77F-3.MSP430C092 Password Access.78F-4.Allow Access to BSL.79F-5.MSP430 Password Access.80F-6.Enable Ultra-Low-Power Debug Mode.824List of FiguresSLAU157AIMay 2005Revised June 2015Submit Documentation FeedbackCopyright 20052015,Texas Instruments IList of Tables1-1.System Requirements.102-1.Device Architecture,Breakpoints,and Other Emulation Features.173-1.Availability of EnergyTrace and EnergyTrace+Modes.243-2.EnergyTrace Technology Control Bar Icons.295SLAU157AIMay 2005Revised June 2015List of TablesSubmit Documentation FeedbackCopyright 20052015,Texas Instruments IncorporatedPrefaceSLAU157AIMay 2005Revised June 2015Read This FirstAbout This ManualThis manual describes the use of TI Code Composer Studio IDE v6.1(CCS v6.1)with the MSP430ultra-low-power microcontrollers.This document applies only for the Windows version of the CodeComposer Studio IDE.The Linux version is similar and,therefore,is not described separately.How to Use This ManualRead and follow the instructions in the Get Started Now!chapter.This chapter includes instructions oninstalling the software and describes how to run the demonstration programs.After you see how quick andeasy it is to use the development tools,TI recommends that you read all of this manual.This manual describes only the setup and basic operation of the software development environment butdoes not fully describe the MSP430 microcontrollers or the complete development software and hardwaresystems.For details on these items,see the appropriate TI documents listed in Section 1.3,ImportantMSP430 Documents on the DVD and Web,and in Related Documentation From Texas Instruments.This manual applies to the use of CCS with the TI MSP-FET,MSP-FET430UIF,eZ-FET,and eZ430development tools series.These tools contain the most up-to-date materials available at the time of packaging.For the latestmaterials(including data sheets,users guides,software,and application information),visit the TI MSP430web site at or contact your local TI sales office.Information About Cautions and WarningsThis document may contain cautions and warnings.CAUTIONThis is an example of a caution statement.A caution statement describes a situation that could potentially damage yoursoftware or equipment.WARNINGThis is an example of a warning statement.A warning statement describes a situation that could potentiallycause harm to you.The information in a caution or a warning is provided for your protection.Read each caution and warningcarefully.Code Composer Studio,MSP430,E2E,EnergyTrace are trademarks of Texas Instruments.IAR Embedded Workbench is a registered trademark of IAR Systems.ThinkPad is a registered trademark of Lenovo.Microsoft,Windows,Windows Vista,Windows 7 are registered trademarks of Microsoft Corporation.All other trademarks are the property of their respective owners.6Read This FirstSLAU157AIMay 2005Revised June 2015Submit Documentation FeedbackCopyright 20052015,Texas Instruments IRelated Documentation From Texas InstrumentsRelated Documentation From Texas InstrumentsCCS v6.1 documentationMSP430 Assembly Language Tools Users Guide(SLAU131)MSP430 Optimizing C/C+Compiler Users Guide(SLAU132)MSP430 development tools documentationMSP430 Hardware Tools Users Guide(SLAU278)eZ430-F2013 Development Tool Users Guide(SLAU176)eZ430-RF2480 Users Guide,(SWRA176)eZ430-RF2500 Development Tool Users Guide(SLAU227)eZ430-RF2500-SEH Development Tool Users Guide(SLAU273)eZ430-Chronos Development Tool Users Guide(SLAU292)MSP-EXP430G2 LaunchPad Experimenter Board Users Guide(SLAU318)Advanced Debugging Using the Enhanced Emulation Module(EEM)With Code Composer StudioVersion 6(SLAA393)MSP430 device data sheetsMSP430 device family users guidesMSP430 x1xx Family Users Guide(SLAU049)MSP430 x2xx Family Users Guide(SLAU144)MSP430 x3xx Family Users Guide(SLAU012)MSP430 x4xx Family Users Guide(SLAU056)MSP430 x5xx and MSP430 x6xx Family Users Guide(SLAU208)MSP430FR4xx and MSP430FR2xx Family Users Guide(SLAU445)MSP430FR57xx Family Users Guide(SLAU272)MSP430FR58xx,MSP430FR59xx,MSP430FR68xx,and MSP430FR69xx Family Users Guide(SLAU367)CC430 device data sheetsCC430 device family users guideCC430 Family Users Guide(SLAU259)If You Need AssistanceSupport for the MSP430 microcontrollers and the FET development tools is provided by the TI ProductInformation Center(PIC).Contact information for the PIC can be found on the TI web site Code Composer Studio specific Wiki page(FAQ)is available,and the TI E2ECommunity support forums for the MSP430 microcontrollers and the Code Composer Studio IDE provideopen interaction with peer engineers,TI engineers,and other experts.Additional device-specificinformation can be found on the MSP430 web site.7SLAU157AIMay 2005Revised June 2015Read This FirstSubmit Documentation FeedbackCopyright 20052015,Texas Instruments IncorporatedIf You Need A8Read This FirstSLAU157AIMay 2005Revised June 2015Submit Documentation FeedbackCopyright 20052015,Texas Instruments IncorporatedChapter 1SLAU157AIMay 2005Revised June 2015Get Started Now!This chapter provides instructions on installing the software,and shows how to run the demonstrationprograms.Topic.Page1.1Software Installation.101.2Flashing the LED.101.3Important MSP430 Documents on the DVD and Web.119SLAU157AIMay 2005Revised June 2015Get Started Now!Submit Documentation FeedbackCopyright 20052015,Texas Instruments IncorporatedSoftware I1.1Software InstallationTo install Code Composer Studio IDE v6.1(CCS),run setup_CCS_x.x.x.x.exe from the DVD.If the CCSpackage was downloaded,extract the full zip archive before running setup_CCS_x.x.x.x.exe.Follow theinstructions shown on the screen.The hardware drivers for the USB JTAG emulators(MSP-FET,MSP-FET430UIF,eZ-FET and eZ430 series)are installed automatically when installing CCS.The parallel-portFET(MSP-FET430PIF)legacy debug interface is no longer supported in this version of CCS.NOTE:The legacy MSP-FET430PIF(parallel port emulator)is not supported by this version of CCS.NOTE:Fully extract the zip archive(setup_CCS_x_x_x.zip)before running setup_CCS_x.x.x.x.exe.NOTE:If the MSP-FET or eZ-FET debugger driver install fails:Under certain conditions(depending on the hardware and operating system that is used),theMSP-FET or eZ-FET driver install may fail on the first attempt.This can lead to unresponsivebehavior on IDEs.To resolve this issue,disconnect the MSP-FET or eZ-FET and then plug itagain,or plug it in to a different USB port,and restart the IDE.Table 1-1.System RequirementsRecommended System RequirementsMinimum System RequirementsProcessorDual Core1.5 GHzRAM4 GB2 GB400 MB(depends on features selected duringFree Disk Space2 GBinstallation)MicrosoftWindowsXP with SP2(32 or 64 bit)orMicrosoftWindowsXP with SP2(32 or 64 bit)orOperating SystemWindows Vistawith SP1(32 or 64 bit)orWindows Vista(32 or 64 bit)orWindows 7(32 or 64 bit)Windows 7(32 or 64 bit)1.2Flashing the LEDThis section demonstrates on the FET the equivalent of the C-language Hello world!introductoryprogram.CCS v6.1 includes C code template files that allow flashing the LED in no time.To get started:1.Start Code Composer Studio by clicking Start All Programs Texas Instruments CodeComposer Studio Code Composer Studio.2.Create a new Project by clicking File New CCS Project.3.Enter a project name.4.Set the Device Family to MSP430 and select the Device Variant to use(for example,MSP430F2274).5.Select Blink The LED in the Project templates and example section.6.Click Finish.NOTE:The predefined examples work with most MSP430 boards.Specific examples areautomatically selected for MSP430G221x,MSP430L092,and MSP430FR59xx devices.Certain MSP430F4xx boards use Port P5.0 for the LED connection,which must be changedmanually in the code.7.To compile the code and download the application to the target device,click Run Debug(F11).10Get Started Now!SLAU157AIMay 2005Revised June 2015Submit Documentation FeedbackCopyright 20052015,Texas Instruments IImportant MSP430 Documents on the DVD and WebCAUTIONNever disconnect the JTAG or emulator USB cable during an active debugsession.Always terminate a running debug session properly(by clicking on theTerminate icon)before disconnecting the target device.8.To start the application,click Run Resume(F8)or click the Play button on the toolbar.See FAQ Debugging#1 if the CCS debugger is unable to communicate with the device.Congratulations,you have just built and tested an MSP430 application!1.3Important MSP430 Documents on the DVD and WebThe primary sources of MSP430 and CCS v6.1 information are the device-specific data sheets and usersguides.The most up-to-date versions of these documents available at the time of production have beenprovided on the DVD included with this tool.The MSP430 web site( thelatest version of these documents.Documents describing the Code Composer Studio tools(Code Composer Studio IDE,assembler,Ccompiler,linker,and librarian)can be found at Code Composer Studio specificWiki page(FAQ)is available at the TI E2ECommunity support forums at provide additional help.Documentation for third party tools,suchas IAR Embedded Workbench for MSP430,can usually be found on the respective third-party website.11SLAU157AIMay 2005Revised June 2015Get Started Now!Submit Documentation FeedbackCopyright 20052015,Texas Instruments IncorporatedImportant MSP430 Documents on the DVD and W12Get Started Now!SLAU157AIMay 2005Revised June 2015Submit Documentation FeedbackCopyright 20052015,Texas Instruments IncorporatedChapter 2SLAU157AIMay 2005Revised June 2015Development FlowThis chapter describes how to use Code Composer Studio IDE(CCS)to develop application software andhow to debug that software.Topic.Page2.1Using Code Composer Studio IDE(CCS).142.2Using the Integrated Debugger.1613SLAU157AIMay 2005Revised June 2015Development FlowSubmit Documentation FeedbackCopyright 20052015,Texas Instruments IncorporatedUsing Code Composer Studio IDE(CCS)2.1Using Code Composer Studio IDE(CCS)The following sections are an overview of how to use CCS.For a full description of the softwaredevelopment flow with CCS in assembly or C,see the MSP430 Assembly Language Tools Users Guide(SLAU131)and the MSP430 Optimizing C/C+Compiler Users Guide(SLAU132).2.1.1Creating a Project From ScratchThis section presents step-by-step instructions to create an assembly or C project from scratch and todownload and run an application on the MSP430(see Section 2.1.2,Project Settings).Also,the MSP430Code Composer Studio Help presents a more comprehensive overview of the process.1