User manual
710
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Creating New Library
mikroBasic PRO for dsPIC30/33 and PIC24 allows you to create your own libraries. In order to create a library in
mikroBasic PRO for dsPIC30/33 and PIC24 follow the steps bellow:
1. Create a new source le, see Managing Source Files
2. Save the le in one of the subfolders of the compiler’s Uses folder:
DriveName:\Program Files\Mikroelektronika\mikroBasic PRO for dsPIC\Uses\
3. Write a code for your library and save it.
4. Add __Lib_Example le in some project, see Project Manager. Recompile the project.
If you wish to use this library for all MCUs, then you should go to Tools › Options › Output settings, and check
Build all les as library box.
This will build libraries in a common form which will work with all MCUs. If this box is not checked, then library will
be built for selected MCU.
Bear in mind that compiler will report an error if a library built for specic MCU is used for another one.
5. Compiled le __Lib_Example.mcl should appear in ...\mikroBasic PRO for dsPIC\Uses\ folder.
6. Open the denition le for the MCU that you want to use. This le is placed in the compiler’s Defs folder:
DriveName:\Program Files\Mikroelektronika\mikroBasic PRO for dsPIC\Defs\
and it is named MCU_NAME.mlk, for example 30F4013.mlk
7. Add the the following segment of code to <LIBRARIES> node of the denition le (denition le is in XML format):
<LIB>
<ALIAS>Example_Library</ALIAS>
<FILE>__Lib_Example</FILE>
<TYPE>REGULAR</TYPE>
</LIB>
8. Add Library to mlk le for each MCU that you want to use with your library.
9. Click Refresh button in Library Manager
10. Example_Library should appear in the Library manager window.
Multiple Library Versions
Library Alias represents unique name that is linked to corresponding Library .mcl le. For example UART library for
30F4013 is different from UART library for 30F6014 MCU. Therefore, two different UART Library versions were made,
see mlk les for these two MCUs. Note that these two libraries have the same Library Alias (UART) in both mlk les.
This approach enables you to have identical representation of UART library for both MCUs in Library Manager.
Related topics: Library Manager, Project Manager, Managing Source Files