Microchip Technology SW006023-2N Data Sheet

Page of 238
Device-Related Features
 2012 Microchip Technology Inc.
DS51686E-page 89
4.5.1
CP0 Register Definitions
When the CP0 register definitions header file is included from an Assembly file, the 
CP0 registers are defined as:
#define _CP0_register_name $register_number, select_number
For example, the IntCtl register is defined as:
#define _CP0_INTCTL $12, 1
When the CP0 register definitions header file is included from a C file, the CP0 registers 
and selects are defined as:
#define _CP0_register_name register_number
#define _CP0_register_name_SELECT select_number
For example, the IntCtl register is defined as:
#define _CP0_INTCTL 12
#define _CP0_INTCTL_SELECT 1
4.5.2
CP0 Register Field Definitions
When the CP0 register definitions header file is included from either an Assembly or a 
C/C++ file, three #defines exist for each of the CP0 register fields.
_CP0_register_name_field_name_POSITION
 – the starting bit location
_CP0_register_name_field_name_MASK
 – the bits that are part of this field are 
set
_CP0_register_name_field_name_LENGTH
 – the number of bits that this field 
occupies
For example, the vector spacing field of the IntCtl register has the following defines:
#define _CP0_INTCTL_VS_POSITION 0x00000005
#define _CP0_INTCTL_VS_MASK     0x000003E0
#define _CP0_INTCTL_VS_LENGTH   0x00000005
4.5.3
CP0 Access Macros
When the CP0 register definitions header file is included from a C file, CP0 access 
macros are defined. Each CP0 register may have up to six different access macros 
defined:
_CP0_GET_register_name ()
Returns the value for register,  
register_name
.
_CP0_SET_register_name (val)
Sets the register, 
register_name
, to val, and 
returns void. Only defined for registers that contain a 
writable field.
_CP0_XCH_register_name (val)
Sets the register, 
register_name
, to val, and 
returns the previous register value. Only defined for 
registers that contain a writable field.
_CP0_BIS_register_name (set)
Sets the register, 
register_name
, to (reg |= set), 
and returns the previous register value. Only defined 
for registers that contain writable bit fields.
_CP0_BIC_register_name (clr)
Sets the register, 
register_name
, to (reg &= ~clr), 
and returns the previous register value. Only defined 
for registers that contain writable bit fields.
_CP0_BCS_register_name (clr, 
set)
Sets the register, 
register_name
, to 
(reg = (reg & ~clr) | set), and returns the previous 
register value. Only defined for registers that contain 
writable bit fields.