Hello Everyone,
I want to generate delay of 1us in mpc5777c, for this i am currently using periodic timer 2 and able to generate delay as minimum as 100us consistently.
fpll0_phi = 192MHz;
fpll0_phi1 = 48MHz;
Code is as below:
int main(void)
{
HW_init();
SystemClk_init();
SIU_Init();
xcptn_xmpl (); /* Configure and Enable Interrupts */
PIT2_init();
/* Loop forever */
while(1)
{
SIU.GPDO[LED1].R = 1;
Delay_Periodic_Timer_2(100); //100us delay
SIU.GPDO[LED1].R = 0;
Delay_Periodic_Timer_2(100); //100us delay
}
return 0;
}
void PIT2_ISR(void)
{
periodic_count++;
PIT.TIMER[2].TFLG.R = 0x00000001;
}
void Delay_Periodic_Timer_2(vuint32_t micro_sec)
{
while(1)
{
if((micro_sec/3) == periodic_count)
{
periodic_count = 0;
break;
}
}
}
But i cant able to generate delay of 1us, also as try to generate delay below 10us behaviour is not determinastic.
Please help to get it done.
Thank you.
解決済! 解決策の投稿を見る。
Your implementation does not make too much sense to me.
I would recommend just to use certain bigger compare value (according to platform frequency) to achieve longer time between interrupt like this for instance for 1s (with 180MHz fplatf):
PIT.TIMER[0].LDVAL.R = 18000000 - 1;
Your implementation does not make too much sense to me.
I would recommend just to use certain bigger compare value (according to platform frequency) to achieve longer time between interrupt like this for instance for 1s (with 180MHz fplatf):
PIT.TIMER[0].LDVAL.R = 18000000 - 1;