EVM5509A LED Example
The LED example is a simple example that demonstrates the most basic usage of the BSL. When run it will:
To run the program, perform the following steps:
Open the led.pjt Code Composer project using Project -> Open and selecting led.pjt. It is in the directory
c:\ti\boards\evm5509a\examples\led
 Click Image to Enlarge: Screenshot of loaded led.pjt
The default install directory for Code Composer is c:\ti. All of the EVM5509A 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:\tievm5509a the led example would be located at c:\tievm5509a\boards\evm5509a\examples\led.
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.
Select the Debug -> Run option under the Debug menu. LED #0 will start blinking slowly.
Move DIP switch #3 up and down, you will see LED #3 change with it.
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 ledprd.pjt and Source subitems. Double click on ledprd.c to see its contents.
LED Example Description
Program execution starts at the beginning of main(). The first call is to EVM5509_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 EVM5509A board. EVM5509_init() should be called before any other BSL functions. You can recognize BSL calls easily because they all start with the prefix EVM5509. The BSL programming interface is described fully in the BSL section of this help file. The BSL functions are included as a library called evm5509bsl.lib.
The LED example demonstrates use of the LED and DIP switch BSL modules. Each has its own initialization function that must be called before other functions in the module. The EVM5509_LED_toggle() call toggles the state of LED #0. A software delay loop:
/* Spin in a software delay loop for about 200ms */
EVM5509_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.
The EVM5509_DIP_get() function reads the state of LED #3. If the switch is pressed down, the call will return 0, prompting the call to EVM5509_LED_on() to turn LED #3 on. If the switch is up, the opposite will occur and EVM5509_LED_off() will be called to turn the LED off. 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 */
EVM5509_waitusec( 200000 );
to:
/* Spin in a software delay loop for about 100ms */
EVM5509_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:
Save the program code that was just modified. Select File -> Save
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.
Load the new led.out executable file. Select File -> Load Program then select led.out in the led\Debug directory in the file browser.
Select the Debug -> Run. LED #0 will start blinking even more slowly than before.
When you are satisfied that the changes you’ve made have actually made the LED blink slower, stop the program by selecting Debug -> Halt.
|