Virtual vs Physical Memory
In all PIC32 architectures, CPU access to memory and peripherals is accomplished through virtual address space. The virtual address space has been segmented to provide the core with flexibility in how it accesses physical memory.
When the CPU is in Kernel mode (default after reset and during exceptions) there are two segments used to access internal memory:
- KSEG0: Internal memory access - cacheable
- KSEG1: Internal memory access - not cacheable
KSEG0 and KSEG1 share the same physical addresses and use Fixed Mapping Translation (FMT) to translate virtual to physical addresses. Every virtual address has its own constant corresponding physical address.
Your application can choose to use cache or not based on the segment used to address physical memory.
There are two segments used to access external (SQI and EBI) memory:
- KSEG2: External memory access - cacheable
- KSEG3: External memory access - not cacheable
There is one segment used to access User (unprivileged) memory:
- KUSEG: User (unprivileged) memory access - cacheable
KUSEG, KSEG2 and KSEG3 use a Memory Management Unit (MMU) with Translation Lookaside Buffer (TLB) to translate virtual to physical addresses. The MMU must be configured by your boot code before using these segments.