Site Index
   Support Home
   C6000 Home
   DaVinci EVM
   EVMDM6437
   EVM6424
   EVMDM642
   XEVM642
   DSKTCI6482
   EVMTCI6482
   DSK6455
   EVM6455
   EVM6418
   DSK6713
   DSK6416
   Ordering Info.
Google

C6000 Site
Support Site
Main Site

EVMDM642 LED Example

The LED example is a simple example that demonstrates the most basic usage of the BSL. When run it will continuously blink LED #0 about 2.5 times per second.

To run the program, perform the following steps:

  1. Open the led.pjt Code Composer project using Project -> Open and selecting led.pjt. It is in the directory

       c:\ti\boards\evmdm642\examples\bsl\led

    The default install directory for Code Composer is c:\ti. All of the EVMDM642 specific documentation refers to file paths as if they were installed in the default location. If you install Code Composer in a different location, please remember to mentally remap the files to their location on you computer while you are reading the documentation. For example, if you install Code Composer in c:\tievmdm642 the led example would be located at c:\tievmdm642.

  2. Load the led.out executable file. Select File -> Load Program. It will open a file browser dialog. Select the led.out file in the led\Debug directory in the file browser and hit "Open" to load the executable file. You must reload the compiled executable every time you make changes to the program.

  3. Select the Debug -> Run option under the Debug menu. LED #0 will start blinking slowly.

  4. When you are satisfied that the program is indeed running correctly, stop the program by selecting Debug -> Halt.

To examine the program code, expand the Projects tree at the left of the workspace, then expand the led.pjt and Source subitems. Double click on led.c to see its contents.


Click Image to Enlarge

LED Example Description
Program execution starts at the beginning of main(). The first call is to EVMDM642_init() which initializes the Board Support Library (BSL). The BSL is a library designed specifically to make it easier to use the components on the EVMDM642 board. EVMDM642_init() should be called before any other BSL functions. You can recognize BSL calls easily because they all start with the prefix EVMDM642. The BSL programming interface is described fully in the BSL section of this help file. The BSL functions are included as a library called evmdm642bsl.lib.

The LED example demonstrates use of the LED BSL modules. Each has its own initialization function that must be called before other functions in the module. The EVMDM642_LED_toggle() call toggles the state of LED #0. A software delay loop:

    /* Spin in a software delay loop for about 200ms */
    EVMDM642_waitusec( 200000 );

introduces a roughly 200 millisecond display before toggling the LED again. This delay loop is responsible for controlling the speed of the blinking LED.

Since all of this code is in a while loop with no termination condition, the program will run forever unless you halt it with Code Composer.

Making Simple Changes
In order to become familiar with Code Composer, this example will take a quick walk through the steps involved in making simple changes to the example. One of the easiest changes to make is to make the LED blink at a slower rate.

View the source for the Blink0() function call. The delay variable contains a value that represents the number of milliseconds to wait inside the while() loop between LED transitions. Change the statement:

    /* Spin in a software delay loop for about 200ms */
    EVMDM642_waitusec( 200000 );

to:

    /* Spin in a software delay loop for about 100ms */
    EVMDM642_waitusec( 100000 );

You should change the delay count from 200000 to 100000 to cut the delay in half, increasing the LED blink rate by a factor of 2.

To try out your new changes you must first:

  1. Save the program code that was just modified. Select File -> Save

  2. Re-compile your program. Every time you make changes to your code you must re-compile the source code to generate a new executable file. Select Project -> Build. Wait for the build to complete before going continuing.

  3. Load the new led.out executable file. Select File -> Load Program then select led.out in the led\Debug directory in the file browser.

  4. Select the Debug -> Run. LED #0 will start blinking even more slowly than before.

  5. When you are satisfied that the changes you’ve made have actually made the LED blink slower, stop the program by selecting Debug -> Halt.

©Copyright 2002-2012 Spectrum Digital, Inc. All Rights Reserved.