OSK5912 LED Example
The LED example is a simple program to demonstrate the most basic usage of the BSL. While running, it will continuously blink LED #0 about 2.5 times per second.
To run the program, perform the following steps:
Load Project
Open the led.pjt Code Composer project using Project -> Open and selecting led.pjt. It is in the directory
c:\ti\boards\osk5912\examples\led
The default install directory for Code Composer is c:\ti. All of the OSK5912 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:\tiosk5912 the led example would be located at c:\tiosk5912.
Load Program
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.
Run Program
Select the Debug -> Run option under the Debug menu. LED #0 will start blinking slowly.
Halt Program
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 OSK5912_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 OSK5912 board. OSK5912_init() should be called before any other BSL functions. You can recognize BSL calls easily because they all start with the prefix OSK5912. The BSL programming interface is described fully in the BSL section of this help file. The BSL functions are included as a library called osk5912bsl.lib.
The LED example demonstrates use of the LED module. You must call the OSK5912_LED_init( ) prior to calling the other functions in the module. The OSK5912_LED_toggle( ) call toggles the state of LED #0. A software delay loop:
/* Spin in a software delay loop for about 200ms */
OSK5912_waitusec( 200000 );
introduces roughly 200 milliseconds delay 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 until you halt the program.
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/faster rate.
View the source for the main( ) function call. The delay loop contains a value that represents the number of microseconds to wait inside the while( ) loop between LED transitions. Changing the statement:
/* Spin in a software delay loop for about 200ms */
OSK5912_waitusec( 200000 );
to:
/* Spin in a software delay loop for about 100ms */
OSK5912_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:
Modify Delay Value
Scroll down to function main( ). In main( ), go to where OSK5912_waitusec( ) is being called. Modify the value from 200000 to 100000.
Save led.c
Save the program code that was just modified. Select File -> Save.
Compile Project
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. If no errors are found during compiling of the project proceed to the next step.
Load Program
Load the new led.out executable file. Select File -> Load Program, then select led.out in the led\Debug directory in the file browser.
Run Program
Select the Debug -> Run, then watch for the LED to be blinking at a faster rate.
Halt Program
When you are satisfied that the changes you’ve made have actually made the LED blink slower, stop the program by selecting Debug -> Halt..
|