The MPLAB® XC8 C Compiler documentation and support materials often state that a compiler feature might only be available for a particular device family. Since the device part number is not a good indicator of its family, a little fact-finding might be necessary to determine if that feature will be available for your project. This article lists the different families currently recognized by the XC8 compiler, describes the device attributes of these families that affect code generation, and shows you how to definitively determine the device family for a given part number.
Microchip produces many 8-bit PIC® microcontrollers, which are currently grouped into the Baseline, Mid-range, or PIC18 families. These families represent devices with instruction sizes of 12-, 14-, and 16-bits, respectively. While the PIC18 device part numbers are easy to place into their family, the other devices can be tricky. A common misconception is that part names beginning with PIC12 are Baseline, and those beginning with PIC16 are Mid-range; however, that is not always correct. The PIC12F1501, for example, is actually in the Mid-range family, and the PIC16F526 is Baseline.
The XC8 compiler further subdivides these three families, based on device features such as instruction set, memory configuration, or available modules. Some compiler features are only available for a particular family, or even a subdivision of that family. When you are choosing a device, this might affect your design and the efficiency of your program, so how can you tell which family a device belongs to?
If you have the MPLAB X IDE installed, you can open the DeviceArchitecture.html file, located in the <ide install dir>/docs directory, to determine the basic family grouping of each device. However, to see the subgrouping, you can check the MPLAB XC8 device INI files that specify device-specific information to the compiler. If you are using MPLAB XC8 v2.10 or higher, there is one INI file for each device and these are located in the <xc8 install dir>/pic/dat/ini directory. If you are using an earlier compiler, there are two INI files, one for PIC18 devices, called picc-18.ini, and the other called picc.ini, for all other devices. These can be found in the <xc8 install dir>/pic/dat directory.
Changing values inside INI files can be detrimental, so first make copies of these files for you to explore.
Regardless of the compiler version, the INI file content is similar. If you want to determine the family for a PIC16F1934 part, for example, open either 16f1934.ini (for compiler versions 2.10 or later) or picc.ini (for earlier compiler versions). Search for the device name in square brackets. This will be followed by an entry called ARCH.
[16F1934]
ARCH=PIC14E
In this example, PIC14E is the designator used by the compiler to represent the family. The following table shows all the designators and what features distinguish the devices they represent.
Designator | Family group | Instruction size and device features | Example device |
---|---|---|---|
PIC12 | Baseline | 12-bit | 16F526 |
PIC12E | Enhanced Baseline | 12-bit, enhanced instructions | 12F529T39A |
PIC12IE | Enhanced Baseline | 12-bit, enhanced instructions, interrupts | 16F527 |
PIC14 | Mid-range | 14-bit | 12F617 |
PIC14E | Enhanced Mid-range | 14-bit, enhanced instructions | 16F1503 |
PIC14EX | Enhanced Mid-range | 14-bit, enhanced instructions, extended data | 16F15356 |
PIC18 | PIC18 | 16-bit | 18F46K22 |
PIC18XV | PIC18 | 16-bit, extended data, vectored interrupts | 18F46K42 |
Here are the benefits of these device features when using XC8; however, note that there may be other device features associated with a family that is not classified by the compiler.
Enhanced Baseline devices with the enhanced instructions include the movlb instruction, which allows for fast bank switching and hence improved code efficiency. These devices might also have an unbanked region of memory that is not common across all data banks.
Baseline devices with interrupts implement interrupt hardware and allow interrupt functions to be defined in C code. Other baseline devices do not support interrupts.
Mid-range devices with the enhanced instructions have several additional instructions that can indirectly access data more efficiently, thus allowing a software (reentrant) stack to be used by functions, and allowing linear (non-banked) access of objects larger than a bank in size.
Enhanced Mid-range devices with extended data have 64 banks of data memory, ideal for projects that require large amounts of RAM.
PIC18 devices with vectored interrupts allow for faster interrupt response by letting you define individual interrupt functions dedicated to one interrupt source.