I have done the same thing sir.
but entering into PIT Handler even if counter is not set to zero.
Even the timing is also getting mismatch. from below calculation it should be 10msec, but it is set to 13msec.
Here BUS_CLOCK = 24MHz, PIT_INT = 10msec
void pit_init()
{
pit_config.enableRunInDebug = false;
PIT_Init(PIT, &pit_config); // PIT PERIPHERAL RUNS ON BUS CLOCK, AS PER USER MANUAL
PIT->MCR = 0x00; // Enable clock for PIT
PIT->CHANNEL[0].LDVAL = 240000;//(BUS_CLOCK*(PIT_INT/1000)); // LOAD VALUE FOR EVERY 10MSEC INTERRUPT
PIT->CHANNEL[0].TCTRL = 0x03; // Start Timer & Interrupt Enable
NVIC_EnableIRQ(PIT_CH0_IRQn);
NVIC_SetPriority(PIT_CH0_IRQn,0);
}
void PIT_CH0_IRQHandler()
{
PIT->CHANNEL[0].TFLG = 0x01; // Disable Interrupt
PIT->CHANNEL[0].TCTRL = 0x00; // Disable timer & Stop timer
PIT->CHANNEL[0].TCTRL = 0x03; // Start Timer & Interrupt Enable
count_l++;
if(count_l >= LED_TOGGLE_VALUE)
{
flag = flag^1;
GPIO_PortToggle(kGPIO_PORTB, 0x20); // toggle led for every 500msec
count_l = RESET;
}
ADC_SetChannelConfig(ADC,&sADC_Config_1);
}
Please reply back..