12.4.1 Initialize PMP

The PMP peripheral requires initialization before any access can be properly processed. Consult the appropriate documentation for the device you are interfacing to and the data sheet for 16-bit device you are using.

If PMP is used, the toolsuite will call void __init_PMP(void) during normal C run-time initialization. If a customized initialization is being used, please ensure that this function is called.

This function should make the necessary settings in the PMMODE and PMCON SFRs. In particular:

  • The peripheral should not be configured to generate interrupts: 
PMMODEbits.IRQM = 0
  • The peripheral should not be configured to generate increments:
 PMMODEbits.INCM = 0 
The compiler will modify this setting during run-time as needed.
  • The peripheral should be initialized to 16-bit mode:
 PMMODEbits.MODE16 = 1
 The compiler will modify this setting during run-time as needed.
  • The peripheral should be configured for one of the MASTER modes:
 PMMODEbits.MODE = 2 or PMMODEbits.MODE = 3
  • Set the wait-states PMMODEbits.WAITB, PMMODEbits.WAITM, and 
PMMODEbits.WAITE as appropriate for the device being connected.
  • The PMCON SFR should be configured as appropriate making sure that the chip select function bits PMCONbits.CSF match the information communicated to the compiler when defining memory spaces.

A partial example might be:

 void __init_PMP(void) {
   PMMODEbits.IRQM = 0;  
   PMMODEbits.INCM = 0;
   PMMODEbits.MODE16 = 1;
   PMMODEbits.MODE = 3;
   /* device specific configuration of PMMODE and PMCCON follows */
 }