Subsections

4.5.8 The Library

The PIC14 library currently only contains support routines required by the compiler to implement multiplication, division, and floating point support. No libc-like replacement is available at the moment, though many of the common sdcc library sources (in device/lib) should also compile with the PIC14 port.

4.5.8.1 Enhanced cores

SDCC/PIC14 has experimental support for devices with the enhanced 14-bit cores (such as pic12f1822). Due to differences in required code, the libraries provided with SDCC (libm.lib and libsdcc.lib) are now provided in two variants: libm.lib and libsdcc.lib are compiled for the regular, non-enhanced devices. libme.lib and libsdcce.lib (note the trailing 'e') are compiled for enhanced devices. When linking manually, make sure to select the proper variant!

When SDCC is used to invoke the linker, SDCC will automatically select the libsdcc.lib-variant suitable for the target device. However, no such magic has been conjured up for libm.lib!

4.5.8.2 Accessing bits of special function registers

Individual bits within SFRs can be accessed either using <sfrname>bits.<bitname> or using a shorthand <bitname>, which is defined in the respective device header for all <bitname>s. In order to avoid polluting the global namespace with the names of all the bits, you can #define NO_BIT_DEFINES before inclusion of the device header file.


4.5.8.3 Naming of special function registers

If NO_BIT_DEFINES is used, individual bits of the SFRs can be accessed as <sfrname>bits.<bitname>. With the 3.1.0 release, the previously used <sfrname>_bits.<bitname> (note the underscore) is deprecated. This was done to align the naming conventions with the PIC16 port and competing compiler vendors. To avoid polluting the global namespace with the legacy names, you can prevent their definition using #define NO_LEGACY_NAMES prior to the inclusion of the device header.

You must also #define NO_BIT_DEFINES in order to access SFRs as <sfrname>bits.<bitname>, otherwise <bitname> will expand to <sfrname>bits.<bitname>, yielding the undefined expression <sfrname>bits.<sfrname>bits.<bitname>.

4.5.8.4 error: missing definition for symbol “__gptrget1”

The PIC14 port uses library routines to provide more complex operations like multiplication, division/modulus and (generic) pointer dereferencing. In order to add these routines to your project, you must link with PIC14's libsdcc.lib. For single source file projects this is done automatically, more complex projects must add libsdcc.lib to the linker's arguments. Make sure you also add an include path for the library (using the -I switch to the linker)!

4.5.8.5 Processor mismatch in file “XXX”.

This warning can usually be ignored due to the very good compatibility amongst 14bit PIC devices.

You might also consider recompiling the library for your specific device by changing the ARCH=p16f877 (default target) entry in device/lib/pic/Makefile.in and device/lib/pic/Makefile to reflect your device. This might even improve performance for smaller devices as unnecessary BANKSELs might be removed.