You are on page 1of 6

Lab 3.

Board Support Library and the First program


OSK5912 BSL
The Board Support Library (BSL) provides a C-language interface for configuring and
controlling all onboard devices. The library consists of discrete modules that are built and
archived into a library file. Each module represents an individual API and is referred to
simply as an API module. The module granularity is structured so each device is
implemented in an individual API module. The goal of the BSL is to provide a level of
hardware abstraction and software standardization that improves development time and
portability.
The BSL contains the following modules:

Libraries and Include Files


In its most basic form, using the BSL is just a matter of:
1) Linking the BSL in with your code.
2) Referencing the appropriate include (osk5912_###.h) files for each module (see the
API descriptions for each functions requirements).
3) Calling the functions themselves, starting with OSK5912_init().
The libraries and include files reside in the /lib directory and /include directories of
the OSK5912 directory. The full paths to these directories are:
c:\ti\boards\osk5912\lib\
c:\ti\boards\osk5912\include
Using the BSL
The Code Composer Projects that come with the OSK automatically includes the lib and
include paths above so you dont need to manually include them in the search paths. To
include the osk5912bsl.lib file for example, select Project _ Add Files to Project for the
file path you can type or search for:
c:\ti\boards\osk5912\lib\osk5912bsl.lib.
If you choose to specify your search paths, the library search path is specified on the same
tab as the library file and the include search path is specified by selecting Project _ Build
Options, and setting the "Include Search Path" field in the preprocessor section of the
compiler tab.

Customizing the BSL


The BSL source code is available in the lib directory along with the library itself. You
may extend or modify the source code and build your own version of the library. You can
also include the BSL source files directly into your application for greater control. One
useful technique while debugging is to use Code Composers ability to open multiple
projects simultaneously to open both your application and the BSL at the same time.
The debugger will treat the BSL almost as if the source code for both projects were
actually part of the same project.
Project Checklist
The following are things to check when creating your own project:

LED Example
Description:
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.
Perform the following steps to run the LED example:
1) Load project [ led.pjt ]
[ To Load Project ] Select the tab Project _ Open, then select led.pjt in the directory
c:\ti\boards\osk5912\examples\led. ]
[ NOTE: The default install directory for Code Composer is c:\ti. All of the OSK5912
specific documentation refers to file paths as if Code Composer is installed at the default
location. If Code Composer is in a different location, please remember to mentally remap
the files to the other location while reading this document. For example, if Code
Composer is installed at in c:\tiosk5912 the led example would be located at
c:\tiosk5912\boards\osk5912\examples\led. ]
2) Load program [ led.out ]
[ To Load Program ] Select tab File _ Load Program. It will open a file browser dialog.
Select the led.out file in the Debug directory in the file browser and hit "Open" to load.
[ NOTE: Recompile the program every time changes are made. ]
3) Run program [ led.out ]
[ To Run Program ] Select tab Debug _ Run. LED #0 will be blinking slowly.
4) Halt program [ led.out ]
[ To Halt Program ] Select tab Debug _ Halt. Halt the program when you are satisfied
with the LED demo.
LED Example Description
LED program starts at the beginning of main( ). The first call is to OSK5912_init( ) which
will initialize 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.
To examine the program code, expand the Projects tree at the left of the workspace, then
expand the led.pjt and Source sub items. Double click on led.c to view the code.

Making 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. Change 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 loop 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 [ led.c ]
[ To Save ] Select tab File _ Save
2) Re-compile [ led.pjt ]
[ To Compile ] Select Project _ Build. A status of the build will pop up. When no errors
are found the project successfully compiled.
3) Re-load [ led.out ]
[ To Load Program ] Select tab File _ Load Program. Select led.out file in the Debug
directory.
4) Run program [ led.out ]
[ To Run Program ] Select tab Debug _ Run. LED #0 will start blinking faster than
before.
5) Halt program [ led.out ]
[ To Halt Program ] Select tab Debug _ Halt. Halt the program when you are satisfied
with the LED demo.
Other changes to be made involved the other LED on the OSK5912. Simple refer to LED
1 by switching to the instance of 0 in the toggle() function with a 1.
The other LED functions in the BSL are available and can be added to the project.

You might also like