4.4.7 How Can I Implement a Delay in My Code?

Using a device timer to generate a delay is the best method. If no time is available, then you can use the library functions _delay32, __delay_ms, or __delay_us, as they are described in the following document. It is included in the compiler distribution or can be downloaded from the Microchip Technology website, www.microchip.com/.

MPLAB® XC32 Language Tools Libraries Reference Manual for PIC32A MCU” (DS-50003838)