Datasheet

CREATING NEW LIBRARY
mikroC PRO for AVR allows you to create your own libraries. In order to create a
library in mikroC PRO for AVR follow the steps bellow:
1. Create a new C source file, see Managing Source Files
2. Save the file in the compiler's Uses folder:
DriveName:\ProgramFiles\Mikroelektronika\mikroC PRO for
AVR\Uses\__Lib_Example
3. Write a code for your library and save it.
4. Add __Lib_Example file in some project, see Project Manager. Recompile the project.
5. Compiled file __Lib_Example.mcl should appear in
...\mikroC PRO for AVR\Uses\ folder.
6. Open the definition file for the MCU that you want to use. This file is placed in the
compiler's Defs folder:
DriveName:\Program Files\Mikroelektronika\mikroC PRO for AVR\Defs\
and it is named MCU_NAME.mlk, for example ATMEGA16.mlk
7. Add the Library_Alias and Library_Name at the end of the definition file, for
example #pragma SetLib([Example_Library, __Lib_Example])
8. Add Library to mlk file 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
file. For example UART library for ATMEGA16 is different from UART library for
ATMEGA128 MCU. Therefore, two different UART Library versions were made, see
mlk files for these two MCUs. Note that these two libraries have the same Library
Alias (UART) in both mlk files. This approach enables you to have identical repre-
sentation of UART library for both MCUs in Library Manager.
Related topics: Library Manager, Project Manager, Managing Source Files
96
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Environment
mikroC PRO for AVR
CHAPTER 2