C28x Creating a Static Library from Modular Code
From Texas Instruments Embedded Processors Wiki
Contents |
Introduction
This wiki will show you how to create, with the help of an example, a static library in CCS4 from modular source code that can then be reused in other projects
Folder Structure
We have taken the pid_reg3 source and header file from an old version of the Digital Motor Control (DMlibrary and created a new library from it. We used the following directory structure( see Table and Figure below)
Once the directory structure is in place we copied over pid_reg3.c(from the old library) into the source folder and its associated header files,pid_reg3.h and dmctype.h into the include folder.
Creating the Library in CCSv4
Creating the project in CCSv4
|
Start up CCS with the workspace in the source folder C:\TI\controlSUITE\libs\DMC\PID\v100\source and start a new project | | |
| Continue through the successive pop-up menus until you reach the following popup screen. Select the output type to be aStatic Library | |
|
Create a macros.ini file with the following contents and place it in the project folder, INSTALLROOT_TO_PID = ../../
The effect is essentially, We will show you how to use these macros in the coming section
Once you have created the macros.ini file, delete the project and re-import into the workspace. The reason for doing this is that the macros.ini file is only read when the project is first imported. The workspace should look like this
|
|
Build Settings
Go to the Build properties for the project and under Tool Settings -> C2000 Compiler -> Include Options add the following path to the list of search paths,${INSTALLROOT_TO_PID}/include
Under Runtime Model Options, select the large memory model and the unified memory option. If you will be using floaring point or CLA support, select the appropriate boxes
NOTE: If you build your library without fpu32 support and then decide to use it in a floating point device, you will need to recompile with floating point support. We usually add fpu32 as a suffix to the library to distinguish it from its fixed point counterpart, e.g C28x_DMC_PID_fpu32.lib
Finally go to the Build Settings tab and edit the artifact name as follows, ${INSTALLROOT_TO_PID}/lib/C28x_DMC_PID
This way you don’t have to manually copy the .lib output into the lib folder and if the version number of the project changes it will automatically adjust as we are using relative paths instead of full path names.
Finally, compile the project. The built library(.lib) file should be in the lib folder
Using the Library
Go to the project’s build propeties, Tool Settings -> C2000 linker -> File Search Path and add C28x_DMC_PID.lib as an included library and where to find it in the search path
as ${INSTALLROOT_TO_PID}/v100/libs
All that’s left is to include the header file pid_reg3.h in the project header file, HVACI_Scalar.h. Now you will be able to use the functions defined in pid_reg3 in your code
