Grace

17
Grace for Code Composer Studio™ IDE Getting Started Guide Literature Number: SLAU476 December 2012

Transcript of Grace

Page 1: Grace

Grace for Code Composer Studio™ IDE

Getting Started Guide

Literature Number: SLAU476

December 2012

Page 2: Grace

Contents

1 Introduction ........................................................................................................................ 41.1 Supported Devices ...................................................................................................... 4

1.2 Purpose of Grace ........................................................................................................ 4

1.3 Grace, MSP430Ware, and Driver Library ............................................................................ 4

2 Installation ......................................................................................................................... 53 Starting a Grace Project ....................................................................................................... 64 Device Configuration ......................................................................................................... 10

4.1 G2xx and F2xx Device Family Peripheral Configuration ......................................................... 10

4.2 FR5xx Device Family Configuration ................................................................................. 12

5 Build the Project ................................................................................................................ 126 GPIO Configuration ........................................................................................................... 137 Grace Snippets ................................................................................................................. 148 Review the Generated Source Code ..................................................................................... 159 Interrupt Handling ............................................................................................................. 15

2 Table of Contents SLAU476–December 2012Submit Documentation Feedback

Copyright © 2012, Texas Instruments Incorporated

Page 3: Grace

www.ti.com

List of Figures

1 CCS Setup, Processor Support ........................................................................................... 5

2 CCS Setup, Select Components.......................................................................................... 5

3 Workspace Launcher, Select a Workspace ............................................................................. 6

4 New CCS Project ........................................................................................................... 6

5 New CCS Project Setup ................................................................................................... 7

6 Grace Welcome Screen.................................................................................................... 8

7 Device Overview ............................................................................................................ 9

8 Screen Tips .................................................................................................................. 9

9 Timer_A3 Use Cases ..................................................................................................... 10

10 Basic User Mode .......................................................................................................... 11

11 Configure Timer Peripheral .............................................................................................. 12

12 Build a Project ............................................................................................................. 12

13 GPIO Configuration, Pinout View ....................................................................................... 13

14 GPIO Configuration, Power User View ................................................................................. 13

15 Activate Grace Snippets .................................................................................................. 14

16 Header File for Grace Snippets.......................................................................................... 14

17 Project Explorer, Generated Source .................................................................................... 15

18 Timer Capture/Compare Block #0....................................................................................... 15

19 Interrupt Vector List ....................................................................................................... 16

20 Interrupt Vector Code ..................................................................................................... 16

Code Composer Studio, MSP430 are trademarks of Texas Instruments.

3SLAU476–December 2012 List of FiguresSubmit Documentation Feedback

Copyright © 2012, Texas Instruments Incorporated

Page 4: Grace

Getting Started GuideSLAU476–December 2012

Grace for Code Composer Studio™ IDE

1 Introduction

Grace aids developers who are using MSP430™ microcontrollers by providing an intuitive way ofconfiguring devices. The user can select from a variety of use cases and add customized settings. Gracethen generates the configuration code.

1.1 Supported Devices

At present, Grace supports the following devices:

• All MSP430F2xx devices

• All MSP430G2xx devices (MSP430 Value Line)

• All MSP430FR57xx, MSP430FR58xx, MSP430FR59xx (FRAM devices)

1.2 Purpose of Grace

The code that is generated by Grace covers only device initialization. After this initialization, the firstfunction that is usually executed in the main function, and there is no further interaction of Grace with theuser code.

1.3 Grace, MSP430Ware, and Driver Library

For the MSP430FR5xx devices, a low-level library (Driver Library) is available. Grace uses the DriverLibrary for configuring the MCU. The Driver Library is a part of MSP430Ware; therefore, Grace requiresthat MSP430Ware is installed.

Users can use Driver Library in their own user code. Direct register access is also possible.

The MSP430G2xx and MSP430F2xx devices are not supported by the Driver Library. Therefore, Gracedirectly accesses the peripheral registers.

The Driver Library API documentation can be found in the TI resource explorer. Select "TI ResourceExplorer" from the "View" menu. Then select MSP430Ware→Libraries→ DriverLib→User's Guide for thedocumentation.

4 Grace for Code Composer Studio™ IDE SLAU476–December 2012Submit Documentation Feedback

Copyright © 2012, Texas Instruments Incorporated

Page 5: Grace

www.ti.com Installation

2 Installation

Grace is included in the Code Composer Studio 5 default installation for MSP430. If you do not haveGrace installed, you can reinstall it by running the CCSv5 setup (see Figure 1), and selecting the Graceinstallation option (see Figure 2).

Figure 1. CCS Setup, Processor Support

Figure 2. CCS Setup, Select Components

5SLAU476–December 2012 Grace for Code Composer Studio™ IDESubmit Documentation Feedback

Copyright © 2012, Texas Instruments Incorporated

Page 6: Grace

Starting a Grace Project www.ti.com

3 Starting a Grace Project

When starting CCS, you can select a workspace for your projects. In most cases, the default setting isfine, so click OK (see Figure 3).

Figure 3. Workspace Launcher, Select a Workspace

When CCS has finished the startup process, start a new Grace-enabled MSP430 project.

1. Click "File"→ "New" → "CCS Project" (see Figure 4).

Figure 4. New CCS Project

6 Grace for Code Composer Studio™ IDE SLAU476–December 2012Submit Documentation Feedback

Copyright © 2012, Texas Instruments Incorporated

Page 7: Grace

www.ti.com Starting a Grace Project

2. In the New CCS Project wizard (see Figure 5), chose a name for the Project.

3. Select the MSP430 device that is being used in the drop-down menu.

4. Chose "Empty Grace Project" in the "Project templates and examples" section.

5. Click OK.

Figure 5. New CCS Project Setup

7SLAU476–December 2012 Grace for Code Composer Studio™ IDESubmit Documentation Feedback

Copyright © 2012, Texas Instruments Incorporated

Page 8: Grace

Starting a Grace Project www.ti.com

When the loading process has completed, the Grace Welcome screen opens (see Figure 6). Much usefulinformation is being presented here, including basic usage instructions and helpful links. It is a good ideato spend some time reading this page.

Figure 6. Grace Welcome Screen

8 Grace for Code Composer Studio™ IDE SLAU476–December 2012Submit Documentation Feedback

Copyright © 2012, Texas Instruments Incorporated

Page 9: Grace

www.ti.com Starting a Grace Project

Click on the "Device Overview" link to get an overview of the device's peripherals (see Figure 7). You cannavigate to any peripheral that is shown as a blue box by clicking on it. You can also navigate by clickingon the arrow in the top bar.

Notice the green checkmarks in some of the boxes. These checkmarks indicate that Grace can generateinitialization code for these peripherals.

Figure 7. Device Overview

Click on one of the blue boxes (for example, a Timer) to open the peripheral configuration screen.

Note that configuration of peripherals for the G2xx and F2xx device families differs from configuration forthe FR5xx device families.

Many setting options feature screen tips that are shown when the mouse cursor hovers over aconfigurable item on the screen (see Figure 8).

Figure 8. Screen Tips

9SLAU476–December 2012 Grace for Code Composer Studio™ IDESubmit Documentation Feedback

Copyright © 2012, Texas Instruments Incorporated

Page 10: Grace

Device Configuration www.ti.com

4 Device Configuration

There are two different methods for configuration, depending on the device family you are using. F2xx andG2xx devices use the configuration method similar to Grace 1.x (see Section 4.1). FR5xx devices use thenew Use Case configuration mode (see Section 4.2). These methods are described separately in thefollowing sections.

4.1 G2xx and F2xx Device Family Peripheral Configuration

4.1.1 Overview Screen

The Overview screen allows you to enable a peripheral and presents you with some basic use-cases thatyou can use as a starting point for your own code (see Figure 9). Check the "Enable … in myconfiguration" to allow Grace to configure this peripheral.

Figure 9. Timer_A3 Use Cases

The "Introduction" section gives a short explanation of the peripheral's capabilities. The Use-Cases thatare shown below this introduction contain instructions on how to configure the peripheral. You can alsocopy the User Code for the Use Case by right-clicking on the code itself, chose "Select All" from themenu, right click again, and select "Copy". You can then paste the user code into your own program.

10 Grace for Code Composer Studio™ IDE SLAU476–December 2012Submit Documentation Feedback

Copyright © 2012, Texas Instruments Incorporated

Page 11: Grace

www.ti.com Device Configuration

4.1.2 Basic and Power User Views

The "Basic User" view (see Figure 10) shows the most important configuration options and can bereached via the link at the top. If you require additional options, use the "Power User" view for a morecomplex setup. For most use cases, the Basic User view is sufficient.

Figure 10. Basic User Mode

Note that the settings performed in one view are automatically reflected in the other views. The morecomplex settings that are possible in the Power User view are hidden in the Basic User view. It istherefore possible to switch from the Basic View to the Power User View and back again.

The Register view shows the register settings that result from the selected configuration.

11SLAU476–December 2012 Grace for Code Composer Studio™ IDESubmit Documentation Feedback

Copyright © 2012, Texas Instruments Incorporated

Page 12: Grace

Build the Project www.ti.com

4.2 FR5xx Device Family Configuration

When selecting a peripheral on an FR5xx device, the use cases of the peripheral are presented. Checkthe "Configure" box to allow Grace to configure this peripheral.

Select a use case to enable it and show the available configuration options (see Figure 11). Some UseCases feature an "Advanced Settings" checkbox that enables the setting of additional options; forexample, clock divider settings.

You can go back to the Use Case Selection screen at any time to change the peripheral's operation to adifferent Use Case. Note that the timers allow several use cases to be configured simultaneously. Graceautomatically checks the available timer resources and allows only valid configurations.

Figure 11. Configure Timer Peripheral

5 Build the Project

Press the build button (the hammer icon) on the top to start the build process (see Figure 12). If a target isconnected to the PC, you can start a debug session by clicking the bug icon.

Figure 12. Build a Project

12 Grace for Code Composer Studio™ IDE SLAU476–December 2012Submit Documentation Feedback

Copyright © 2012, Texas Instruments Incorporated

Page 13: Grace

www.ti.com GPIO Configuration

6 GPIO Configuration

GPIO configuration should be the last step when configuring a device (see Figure 13). IOs that are usedfor a peripheral function should be configured in the peripheral view as described in Section 4.1 andSection 4.2.

The GPIO view shows graphical depictions of the available device packages (see Figure 13). It shows thecurrent configuration. Next to each pin is a drop-down menu that allows you to configure the pin as aninput, output, or a specific peripheral function. Note that configuring a pin manually to a peripheral functiondoes not activate the peripheral or configure it to use the pin.

Figure 13. GPIO Configuration, Pinout View

There is also a Power User view in which additional IO settings can be performed (see Figure 14).Switching from one view to the other does not change the configuration. Settings that are made in thePower User view might not be visible in the package views, but they are still present.

Figure 14. GPIO Configuration, Power User View

13SLAU476–December 2012 Grace for Code Composer Studio™ IDESubmit Documentation Feedback

Copyright © 2012, Texas Instruments Incorporated

Page 14: Grace

Grace Snippets www.ti.com

7 Grace Snippets

Grace 2 allows you to insert predefined code templates called "Grace Snippets". These templates aredevice-specific and contain C code that helps program the device. The snippets range from simple portI/O settings to complex interrupt handler functions.

Make sure to activate the Grace snippets as mentioned in the "Getting Started" section of the "Welcome"screen (see Figure 15).

Figure 15. Activate Grace Snippets

To use Grace Snippets, you can insert the code by opening a C file in the editor view and then double-clicking on the snippet on the right side. You can also drag and drop the snippets to the cursor position.

Note that for the FR5xx devices, you have to insert the peripheral specific "!Header file include" at the topof the C file before you can use a snippet for that peripheral (see Figure 16).

Figure 16. Header File for Grace Snippets

14 Grace for Code Composer Studio™ IDE SLAU476–December 2012Submit Documentation Feedback

Copyright © 2012, Texas Instruments Incorporated

Page 15: Grace

www.ti.com Review the Generated Source Code

8 Review the Generated Source Code

After the build, the generated source can be found in the Project Explorer in the src→grace folder (seeFigure 17).

Figure 17. Project Explorer, Generated Source

9 Interrupt Handling

Grace can manage peripheral interrupts very efficiently. The configuration of interrupts is possible in thecorresponding peripheral view (see Figure 18) or in the "Interrupt Vector List" (see Figure 19). Click the"View All Interrupt Handlers" link in the peripheral views to view the Interrupt Vector List.

Figure 18. Timer Capture/Compare Block #0

15SLAU476–December 2012 Grace for Code Composer Studio™ IDESubmit Documentation Feedback

Copyright © 2012, Texas Instruments Incorporated

Page 16: Grace

Interrupt Handling www.ti.com

Figure 19. Interrupt Vector List

The interrupts can be programmed in the InterruptVectors_init.c file, which is located in the Grace sourcefolder (see Figure 20). It can also be accessed by clicking on the "Open Interrupt Vector File" link locatedin the Interrupt Vector List. Add your own code between the "USER CODE START" and the "USER CODEEND" tags in the interrupt function. Do not make any modifications outside these tags, as they areoverwritten at the next build process.

If you chose to remove the interrupt handler code at a later time, any code that you entered is moved tothe end of the file as a comment.

Figure 20. Interrupt Vector Code

16 Grace for Code Composer Studio™ IDE SLAU476–December 2012Submit Documentation Feedback

Copyright © 2012, Texas Instruments Incorporated

Page 17: Grace

IMPORTANT NOTICE

Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, enhancements, improvements and otherchanges to its semiconductor products and services per JESD46, latest issue, and to discontinue any product or service per JESD48, latestissue. Buyers should obtain the latest relevant information before placing orders and should verify that such information is current andcomplete. All semiconductor products (also referred to herein as “components”) are sold subject to TI’s terms and conditions of salesupplied at the time of order acknowledgment.

TI warrants performance of its components to the specifications applicable at the time of sale, in accordance with the warranty in TI’s termsand conditions of sale of semiconductor products. Testing and other quality control techniques are used to the extent TI deems necessaryto support this warranty. Except where mandated by applicable law, testing of all parameters of each component is not necessarilyperformed.

TI assumes no liability for applications assistance or the design of Buyers’ products. Buyers are responsible for their products andapplications using TI components. To minimize the risks associated with Buyers’ products and applications, Buyers should provideadequate design and operating safeguards.

TI does not warrant or represent that any license, either express or implied, is granted under any patent right, copyright, mask work right, orother intellectual property right relating to any combination, machine, or process in which TI components or services are used. Informationpublished by TI regarding third-party products or services does not constitute a license to use such products or services or a warranty orendorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property of thethird party, or a license from TI under the patents or other intellectual property of TI.

Reproduction of significant portions of TI information in TI data books or data sheets is permissible only if reproduction is without alterationand is accompanied by all associated warranties, conditions, limitations, and notices. TI is not responsible or liable for such altereddocumentation. Information of third parties may be subject to additional restrictions.

Resale of TI components or services with statements different from or beyond the parameters stated by TI for that component or servicevoids all express and any implied warranties for the associated TI component or service and is an unfair and deceptive business practice.TI is not responsible or liable for any such statements.

Buyer acknowledges and agrees that it is solely responsible for compliance with all legal, regulatory and safety-related requirementsconcerning its products, and any use of TI components in its applications, notwithstanding any applications-related information or supportthat may be provided by TI. Buyer represents and agrees that it has all the necessary expertise to create and implement safeguards whichanticipate dangerous consequences of failures, monitor failures and their consequences, lessen the likelihood of failures that might causeharm and take appropriate remedial actions. Buyer will fully indemnify TI and its representatives against any damages arising out of the useof any TI components in safety-critical applications.

In some cases, TI components may be promoted specifically to facilitate safety-related applications. With such components, TI’s goal is tohelp enable customers to design and create their own end-product solutions that meet applicable functional safety standards andrequirements. Nonetheless, such components are subject to these terms.

No TI components are authorized for use in FDA Class III (or similar life-critical medical equipment) unless authorized officers of the partieshave executed a special agreement specifically governing such use.

Only those TI components which TI has specifically designated as military grade or “enhanced plastic” are designed and intended for use inmilitary/aerospace applications or environments. Buyer acknowledges and agrees that any military or aerospace use of TI componentswhich have not been so designated is solely at the Buyer's risk, and that Buyer is solely responsible for compliance with all legal andregulatory requirements in connection with such use.

TI has specifically designated certain components as meeting ISO/TS16949 requirements, mainly for automotive use. In any case of use ofnon-designated products, TI will not be responsible for any failure to meet ISO/TS16949.

Products Applications

Audio www.ti.com/audio Automotive and Transportation www.ti.com/automotive

Amplifiers amplifier.ti.com Communications and Telecom www.ti.com/communications

Data Converters dataconverter.ti.com Computers and Peripherals www.ti.com/computers

DLP® Products www.dlp.com Consumer Electronics www.ti.com/consumer-apps

DSP dsp.ti.com Energy and Lighting www.ti.com/energy

Clocks and Timers www.ti.com/clocks Industrial www.ti.com/industrial

Interface interface.ti.com Medical www.ti.com/medical

Logic logic.ti.com Security www.ti.com/security

Power Mgmt power.ti.com Space, Avionics and Defense www.ti.com/space-avionics-defense

Microcontrollers microcontroller.ti.com Video and Imaging www.ti.com/video

RFID www.ti-rfid.com

OMAP Applications Processors www.ti.com/omap TI E2E Community e2e.ti.com

Wireless Connectivity www.ti.com/wirelessconnectivity

Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265Copyright © 2012, Texas Instruments Incorporated