have small question , i am using the snvs HP rtc and its alarm feature of imxrt1050 . which can give interrupt in seconds is it possible to get alarm in milliseconds.
Hi Venu ,
You can use the below function to generate millisecond delay
void delay_ms(uint32_t delay)
PIT->CHANNEL[kPIT_Chnl_0].LDVAL = 24000*delay;
PIT_ClearStatusFlags(PIT, kPIT_Chnl_0, kPIT_TimerFlag);
if you need a alarm for every milli second , then enable the interrupt .
void Enable_Timer_Interrupt(pit_chnl_t channel)
PIT_EnableInterrupts(PIT, channel, kPIT_TimerInterruptEnable);
Check below , i have configured Timers to generate interrupt every 500ms , 1 second and 2 seconds .
PIT_SetTimerPeriod(PIT, kPIT_Chnl_1, 12000000); // 24,000,000 is for 1 sec 24,000 for 1ms
PIT_SetTimerPeriod(PIT, kPIT_Chnl_2, 24000000); // 24,000,000 is for 1 sec 24,000 for 1ms
PIT_SetTimerPeriod(PIT, kPIT_Chnl_3, 48000000); // 24,000,000 is for 1 sec 24,000 for 1ms
Hope this will help .
To work with millisecond interrupts I would suggest you use either the General Purpose Timer or the Quad Timer. You can refer to the SDK to see the example projects of these two timers to see how to make the proper configurations.