AnsweredAssumed Answered

MPC5777C generation of 1us delay

Question asked by Harshal Shirude on Oct 5, 2017
Latest reply on Oct 9, 2017 by David Tosenovjan

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.

Outcomes