Gagan,
Here is a simple example for the KL25Z MCU.
// PIT Initialization
SIM_SCGC6 |= SIM_SCGC6_PIT_MASK; // Enable the clock to the PIT module
PIT_LDVAL0 = 8000000; // Default start value
PIT_MCR = PIT_MCR_FRZ_MASK; // Enable clock for timer, freeze timer in debug mode
PIT_TCTRL0 = PIT_TCTRL_TIE_MASK | PIT_TCTRL_TEN_MASK; // Enable timer and timer interrupt
// Initialize the NVIC to enable the PIT interrupt
NVIC_ICPR |= 1 << ((INT_PIT - 16) % 32);
NVIC_ISER |= 1 << ((INT_PIT - 16) % 32);
In CW 10.3 and for FRDM-KL25Z the GCC compiler is used, this compiler creates the vector table with the names of each interrupt. So it is just necessary to name you ISR with the same name in the vector table (PIT_IRQHandler in the kinetis_sysinit.c).
void PIT_IRQHandler()
{
PIT_TCTRL0 = 0; // Disable timer
PIT_TFLG0 |= PIT_TFLG_TIF_MASK; // Clear the timer interrupt flag
PIT_TCTRL0 |= PIT_TCTRL_TEN_MASK | PIT_TCTRL_TIE_MASK; // Enable timer
}
Hope it helps.
Regards,
Tomas