Stellaris LM4F120 LaunchPad Blink the RGB

From Texas Instruments Wiki

Jump to: navigation, search
Translate this page to   




LaunchPad Resource Portal  LaunchPadRocket.png


This wiki is open and can be edited by all!

More information available @ www.ti.com/launchpad


LaunchPad Banner.jpg

Contents

Project0 Your First Project

Introduction

Stellaris LaunchPad: Project Zero

In this project we will walk you through the process of importing your first project and modifying the project behavior. This Lesson will verify that your tools are properly installed and that you can edit, compile, download and debug your code on the Stellaris® LM4F120 LaunchPad.

We will cover:

Download and Install Software You Will Need

There are two ways to get all the tools you will need. One is to download a single package that contains all of the installers and documentation. The alternate if you already have one or more of the components needed is to download them separately. Use the separate method to obtain Code Composer Studio (CCS) for Linux.

Single Download

Use this if you don't have CCS or have not used Stellaris devices before.

  1. Download the EK-LM4F120XL-CCS package from here.
    You can also download a package for one of the other supported compilers. This tutorial covers only CCS. The process should be similar.
  2. Unzip the package.
  3. Find the CCS Installer in the Software\CCS directory of the download package.
  4. Find the StellarisWare installer in the Software\StellarisWare directory.
  5. Note the location of the Software\ICDI directory. You will use this in a later step to install device drivers.

Individual Downloads

Use this if you already have CCS or one of the other components.

  1. Download the ICDI Drivers. Extract the zip file and note its location for later use.
  2. Download the SW-EK-LM4F120XL package from here.
  3. Download Code Composer Studio. This tutorial assumes you use the Windows version.
    Linux support for this LaunchPad's ICDI interface in CCS is considered Beta at this time. See this forum thread for more information

Optional Files

Hardware Setup and Driver Installation

  1. Extract the Stellaris ICDI Drivers.
  2. Plug the LaunchPad into your PC's USB port
  3. Follow the driver installation guide.
  4. Your device manager should show three Stellaris devices like the image below.
Device Manager with properly installed ICDI Drivers


Import Project0 files into Code Composer Studio

Test Project0 Example

Before moving on be sure to test the project0 example prior to making any modifications.

If you run into trouble double check device manager and the three Stellaris devices are listed as mentioned above. Occasionally you must re-install the drivers even though the devices are listed as working correctly. If you suspect the drivers are working and the problem is CCS related try LMFlashProgrammer to download one of the binary files that come with StellarisWare. All of these binaries are tested and known to work. Make sure you select an ek-lm4f120xl binary that you have not rebuilt or modified.

The project0 example should be blinking the LED alternating between RED and BLUE.

Modify Project0

If you are still in a debug session terminate the session and return to the CCS Edit perspective.

Note that all three LED colors are already defined on lines 36-38 of project0.c

 
 #define RED_LED   GPIO_PIN_1
 #define BLUE_LED  GPIO_PIN_2
 #define GREEN_LED GPIO_PIN_3

Note on line 75 of project0.c that all three LED GPIO pins have been configured for output mode

GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED);

Copy Lines 82 through 90 of project0.c. Note that the 2nd parameter serves as a bit mask for which pins to write.

//
// Turn on the LED
//
GPIOPinWrite(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED, RED_LED);

//
// Delay for a bit
//
SysCtlDelay(2000000);

Paste the copied lines below line 100. The 'while(1)' should now look like this:

while(1)
{
    //
    // Turn on the LED
    //
    GPIOPinWrite(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED, RED_LED);

    //
    // Delay for a bit
    //
    SysCtlDelay(2000000);

    //
    // Turn on the LED
    //
    GPIOPinWrite(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED, BLUE_LED);

    //
    // Delay for a bit
    //
    SysCtlDelay(2000000);
    
    //
    // Turn on the LED
    //
    GPIOPinWrite(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED, RED_LED);

    //
    // Delay for a bit
    //
    SysCtlDelay(2000000);
}

Change line 105 from RED_LED to GREEN LED.

GPIOPinWrite(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED, GREEN_LED);

Download and Debug your Project0

Click the bug icon to build, download and debug your changes. CCS will change back to the Debug Perspective. The code will run until the first line of main and then stop. Click the run icon to resume operation. Observe red, blue and green blinking pattern.

Play with CCS to pause, set breakpoints and get to know the environment.

Experiment

Toast Success

Congratulations. You have just imported, modified, downloaded and debugged your first StellarisWare Project.

Leave a Comment

Comments

Comments on Stellaris LM4F120 LaunchPad Blink the RGB


Gregrhunter said ...

Link for driver instalation guide is broken it is here: http://www.ti.com/lit/ml/spmu287a/spmu287a.pdf

Why can't I edit the wiki?

--Gregrhunter 13:03, 26 April 2013 (CDT)

Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox