Then, clearing the core timer register to zero for each interrupt is not good practice.
It will cause the time interval to creep, caused by the time passing from Compare register match and triggering the interrupt, until timer update is processed in the interrupt handler.
With the system clock frequency used, this seem to be about 1.2 microcecond.
Clearing the core timer Count register, will also make it impossible to use the core timer for other time measurement purposes at the same time.
A better solution is to increment the Compare register with the interval value, and leave Count register unchanged:
// /* This is not smart, Clearing the Core timer, */
// _CP0_SET_COUNT(0); // set core timer counter to 0 /* will cause interrupt timing to drift. */
// _CP0_SET_COMPARE( CORE_TICKS); // must set CP0_COMPARE again after interrupt.
/* Instead, Increment Compare register with Core Ticks value. */
_CP0_SET_COMPARE( _CP0_GET_COMPARE() + CORE_TICKS);
Including the file p32xxxx.h is some remains from C32 compiler, and is redundant,
when xc.h have been included.