5.2 Using the Fixed-Point Libraries

Building an application which utilizes the fixed-point libraries requires two types of files: header files and library files. Understanding fixed-point function naming conventions is needed for use.

Header Files

All standard C library entities are declared or defined in one or more standard headers. To make use of a library entity in a program, write an include directive that names the relevant standard header. The contents of a standard header are included by naming them in an include directive, as in:

#include <libq.h> /* include fixed-point library */

The standard headers can be included in any order. Do not include a standard header within a declaration. Do not define macros that have the same names as keywords before including a standard header.

A standard header never includes another standard header.

Library Files

The archived library files contain all the individual object files for each library function.

When linking an application, the library file (libq-elf.aor libq-dsp-elf.a ) must be provided as an input to the linker (using the --library or -l linker option), such that the functions used by the application may be linked into the application. Also, the linker options -lq and -lq-dsp must be used when linking the respective libraries.

A typical C application will require these library files: libc99-elf.a, libm-elf.a and libc99-pic30-elf.a. These libraries will be included automatically if linking is performed using the compiler.

Function Naming Conventions

Signed fixed-point types are defined as follows:

Qn_m

where:

  • n is the number of data bits to the left of the radix point
  • m is the number of data bits to the right of the radix point
Note: A sign bit is implied.

For convenience, short names are also defined:

Exact Name# Bits RequiredShort Name
_Q0_3132_Q31