PIC32MZ Modes of Operation

Last modified by Microchip on 2023/11/09 09:01

The PIC32MZ Central Processing Unit (CPU) runs at one of three privilege levels, User, Kernel, and Debug. These modes determine the addresses, registers, and instructions that are available to a program.

Kernel Mode

The core enters Kernel mode at reset and when an exception is recognized. While in Kernel mode, the software has access to the entire 4 GB virtual address space, as well as the CP0 registers.

Back to top

User Mode

User mode access is restricted to the first 2 GB of the address space (0x00000000 through 0x7FFFFFFF) and can be excluded from accessing CP0 functions. Accessing a virtual address above 0x7FFFFFFF in User mode will cause an exception.

Kernel and User modes are designed to support the needs of operating systems, allowing a system designer to partition code between privileged and unprivileged software.

Although it can sound as if Kernel mode is for OS-based applications and User mode is the simple everyday mode, the reverse is the truth. Most PIC32MZ applications will start out in, and never leave Kernel mode.

Back to top

Debug Mode

Debug mode is entered on a debug exception. While in Debug mode, the software has access to all Kernel mode addresses and functions, as well as debug segment dseg, which overlays part of the kernel segment KSEG3.

Figure 50-13 (from the PIC32 Family Reference Manual) shows the different memory maps for each mode:

Figure 50-13: CPU Modes

kuseg, kseg0, kseg1, kseg2, kseg3:

The MIPS32 virtual address space is partitioned into five, traditional, fixed-size segments:

kuseg (2 GB):

  • addresses are cacheable and accessible in both User mode and Kernel mode
  • designed to be used by User mode programs

kseg0 (512 MB):

  • addresses are cacheable and accessible in Kernel mode only
  • designed to be used by Kernel mode programs

kseg1 (512 MB):

  • addresses are noncacheable and accessible in Kernel mode only
  • designed to be used by Kernel mode programs
  • designed for access to peripheral devices and for code that requires noncacheable access, including initialization code

kseg2/3 (1 GB total):

  • addresses are cacheable and accessible in Kernel mode only
  • designed to be used by Kernel mode programs

Note that the segment boundaries are fixed and never change.

Back to top