Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Microchip PIC24F Peripheral Library

Getting Started
Using the Peripheral Libraries - PIC24F Family
These libraries provide a set of common interface functions to initialize and use peripheral modules on Microchip 16-bit
microcontrollers. The libraries have been optimized for code size efficiency.

Building a Project with the Peripheral Library


Building an application which utilizes the 16-bit peripheral libraries requires the library file libpPIC24Fxxx.a and a
header file for each peripheral module. The archived library file contains all the individual object files for each library
function. For each peripheral, the corresponding header file provides all the function prototypes, #defines and typedefs
used by the library.

The library files are of the form libpPIC24Fxxx-elf.a or libpPIC24Fxxx-coff.a (depending on executable/object file
format selected during the compile operation). These library supports all the variants of PIC24F devices as given under
the “Devices Supportedâ€​ heading.

The header files are of the form peripheral.h, where peripheral is the name of the particular peripheral being used
(e.g., pwm.h for PWM Module). There is also a header file GenericTypeDefs.h which consists of easy-to-use typedefs
and frequently-used data types.

When linking an application, the library file ( libpPIC24Fxxx-elf.a or libpPIC24Fxxx-coff.a) must be provided as an
input to the linker (using the --library or -l linker switch) such that the functions used by the application may be
linked into the application.The .a file to be added to the Project window under Library files. When compiling an
application, each header file must be referenced (using #include) by all source files which call a function in the library
or use its symbols or typedefs.

Library Function Calling Convention


The peripheral library contains some functions that do not require any input arguments, some that require single
values or variables as arguments, and some whose arguments can be expressed as a logical AND/AND-OR of several
constants that are pre-defined in the header file.

Each constant included in any of these AND-ed expressions corresponds to the 16-bit mask for a possible selection for
a certain bit or bit-field in a Special Function Register (SFR). Each argument, in turn, typically corresponds to the
value written to an entire SFR. Thus, by logically combining chosen values for every bit-field in the SFR, the complete
initialization value of the SFR is obtained.
To use the AND-OR mask setting, you will need to define the macro (#define USE_AND_OR) at the beginning of

You might also like