Hello,
Am using iMXRT1064 controller. I wanted to generate a blocking delay of msec or usec. where can i find the delay routines in the driver code. Any example would help.
Thanks
Regards
Anuj
Hi,
Have you download RT1064 SDK. There is PIT example in SDK_2.5.0_EVK-MIMXRT1060\boards\evkmimxrt1060\driver_examples\pit
Regards,
Jing
Hi,
Thanks for the reply. I have gone through the PIT driver but it uses an interrupt when timer count is over. i dont want to use interrupt.
my ex function would be
Delayms(1000)
{
loop 1000 times
{
call pit driver function which will wait for 1ms
}
}
how do i achieve this using pit driver or is there any other method.
Regards,
Anuj
Hi,
Then you have to poll TFLG register. After you start PIT, you keep polling TFLG until it become 1.
You can use PIT_GetStatusFlags to read TFLG.
Regards,
Jing
Hello,
I have used the same procedure above. I am facing an issue when multiple timer channels are configured. I am using 2 timer channels. one is configured using PIT component and other 1 is written using code as it is used for blocking delay of usec.
Am using config tool to configure PIT component for channel 0 to generate a recurring delay of 25msec and have a ISR handler which clears the flag according to respective channel status.
I have delay function below which uses channel 1 of PIT but channel 1 is not configured in PIT component. it is configured in below function.
void DelayUs(uint32_t usec){
// /// Set channel 1 period to usec
// PIT_SetTimerPeriod(PIT, kPIT_Chnl_1, USEC_TO_COUNT(usec,PIT_SOURCE_CLOCK));
//
// /// Enable interrupts from channel 1
// PIT_EnableInterrupts(PIT, kPIT_Chnl_1, kPIT_TimerInterruptEnable);
//
// /// Start Timer
// PIT_StartTimer(PIT, kPIT_Chnl_1);
//
//
// /// Check for interrupt flag set in ISR handler
// while(!mainObject.usecFLG){
//
// status = PIT_GetStatusFlags(PIT, kPIT_Chnl_1);
// status &= 0x01 ;
// }
//
// mainObject.usecFLG = false ;
// /// Disable interrupts from channel 1
// PIT_DisableInterrupts(PIT, kPIT_Chnl_1, kPIT_TimerInterruptEnable);
//
// /// Stop Timer
// PIT_StopTimer(PIT, kPIT_Chnl_1);
common ISR handler which clears flags as below
void PIT_IRQHandler(void)
{
volatile uint32_t status ;
status = PIT_GetStatusFlags(PIT, kPIT_Chnl_0);
if(status & kPIT_TimerFlag){
PIT_ClearStatusFlags(PIT, kPIT_Chnl_0, kPIT_TimerFlag);
mainObject.runFLG = true ;
status = PIT_GetStatusFlags(PIT, kPIT_Chnl_1);
if(status & kPIT_TimerFlag){
PIT_ClearStatusFlags(PIT, kPIT_Chnl_1, kPIT_TimerFlag);
mainObject.usecFLG = true ;
}
}
The second channel which is configured in code by above delay function does not work in this case. the 25msec configured for channel 0 is continuously running ok and i get the status as 1 for channel 0 but not of channel 1.
am calling the delay(100) in while loop as below
While(1){
Delay(100);
some code to make pin low
Delay(100);
some code to make pin high
}
the operation gets stuck in above highlighted line in bold while(!mainObject.usecFLG) in delay function.
if i only keep the delay function and not the 25 msec recurring timer then delay function works and status is received ok.
but if channel 0 and channel 1 are used together then delay function does not work.
please let me know what could be the issue.
Thanks
Anuj.
Hi,
Sorry, I don't quite understand your meaning. Can you attach the whole code here?
Regards,
Jing