1.4 Register and Bit Naming Conventions
1.4.1 Register Names
When there are multiple instances of the same peripheral in a device, the Peripheral Control registers will be depicted
as the concatenation of a peripheral identifier, peripheral instance, and control identifier. The control registers section
will show just one instance of all the register names with an ‘x’ in the place of the peripheral instance number. This
naming convention may also be applied to peripherals when there is only one instance of that peripheral in the device
to maintain compatibility with other devices in the family that contain more than one.
1.4.2 Bit Names
There are two variants for bit names:
• Short name: Bit function abbreviation
• Long name: Peripheral abbreviation + short name
1.4.2.1 Short Bit Names
Short bit names are an abbreviation for the bit function. For example, some peripherals are enabled with the EN bit.
The bit names shown in the registers are the short name variant.
Short bit names are useful when accessing bits in C programs. The general format for accessing bits by the short
name is RegisterNamebits.ShortName. For example, the enable bit, EN, in the CM1CON0 register can be set in C
programs with the instruction CM1CON0bits.EN = 1.
Short names are generally not useful in assembly programs because the same name may be used by different
peripherals in different bit positions. When this occurs, during the include file generation, all instances of that short bit
name are appended with an underscore plus the name of the register in which the bit resides to avoid naming
contentions.
1.4.2.2 Long Bit Names
Long bit names are constructed by adding a peripheral abbreviation prefix to the short name. The prefix is unique to
the peripheral, thereby making every long bit name unique. The long bit name for the COG1 enable bit is the COG1
prefix, G1, appended with the enable bit short name, EN, resulting in the unique bit name G1EN.
Important: The COG1 peripheral is used as an example. Not all devices have the COG peripheral.
Long bit names are useful in both C and assembly programs. For example, in C the COG1CON0 enable bit can be
set with the G1EN = 1 instruction. In assembly, this bit can be set with the BSF COG1CON0,G1EN instruction.
1.4.2.3 Bit Fields
Bit fields are two or more adjacent bits in the same register. Bit fields adhere only to the short bit naming convention.
For example, the three Least Significant bits of the COG1CON0 register contain the Mode Control bits. The short
name for this field is MD. There is no long bit name variant. Bit field access is only possible in C programs. The
following example demonstrates a C program instruction for setting the COG1 to the Push-Pull mode:
COG1CON0bits.MD = 0x5;
Individual bits in a bit field can also be accessed with long and short bit names. Each bit is the field name appended
with the number of the bit position within the field. For example, the Most Significant mode bit has the short bit name
MD2 and the long bit name is G1MD2. The following two examples demonstrate assembly program sequences for
setting the COG1 to Push-Pull mode:
Example 1:
MOVLW ~(1<<G1MD1)
ANDWF COG1CON0,F
MOVLW 1<<G1MD2 | 1<<G1MD0
IORWF COG1CON0,F
PIC18F26/45/46Q10
Device Overview
© 2020 Microchip Technology Inc.
Datasheet
DS40001996E-page 19