PIC32MZ Exception Processor Initialization
Starting Up
From a software perspective, reset is almost the same as a general exception, although one from which we're not going to return.
The Central Processing Unit (CPU) responds to reset by entering the Bootstrap mode, starting by fetching instructions from 0xBFC00000. This corresponds (via the Memory Management Unit (MMU)) to the physical address 0x1FC00000 in the uncached KSEG1 region.
Following this, only enough of the CPUs control register state (CP0 registers) is defined so that the CPU can execute uncached instructions.
"Enough state" is interpreted minimally, i.e. only three things are guaranteed in the CP0 Status register:
- The CPU is in Kernel mode (StatusEXL=1).
- Interrupt exceptions are disabled (StatusIE=0).
- Bootstrap exceptions (i.e. exceptions occurring during reset) will vector through uncached entry points (StatusBEV=1).
Furthermore, the caches will be in a random, unusable state, as will the MMU.
MPLAB® XC32 C/C++ Compiler Start-Up Code
The job of modifying this initial CPU state to a state that will run your main() code falls to a small assembly language code stub that is automatically inserted by the MPLAB XC32 compiler.
CPU State on Entry to main()
PIC32MZ CP0 and Interrupt Controller registers are initialized by hardware and MPLAB XC32 Compiler start-up code placing the CPU in the following state upon entry to your main() function:
- Ebase = _ebase_address (= 0x9D000000 for PIC32MZ2048ECG100).
- OFFx registers are initialized by start-up code based on the defined ISRs in your project.
- StatusBEV = 0 (Exception vector entry points changed from the "bootstrap" location to the "normal" location).
- General Exceptions: Ebase (=0x9D000000) + 0x180.
- Interrupt Exceptions: Ebase + OFFx.
- StatusIE = 0 (Interrupt Exceptions Disabled).
- StatusIPL<2:0> = 0 (CPU running at priority level 0).
- INTCONMVEC = 0 (Interrupt controller configured for single-vector mode).
- Cache is enabled and configured in Write-Back with Write Allocation mode.