MPC5777C generation of 1us delay

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPC5777C generation of 1us delay

Jump to solution
795 Views
harshalshirude
Contributor I

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.

Tags (3)
0 Kudos
1 Solution
624 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

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;

View solution in original post

1 Reply
625 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

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;