AnsweredAssumed Answered

k60 flex timer nano seconds delay issue

Question asked by Arun Kumar on Feb 27, 2014

Hello every one,

We recently acquired a few precision adcs,and i need to give the signals exact timing.

I have made a delay function which gives delay in nano seconds,but i always get stuck in the ISR which handles the timer interrupts while debugging.

I cant see how the flag overflows as it is getting stuck there.

 

Here is my delay function.

unsigned long adc_counter = 0;

LDD_TDeviceData *adcdelaytimer;

LDD_TError timerError;

/*

* Description:    Function provides delay in nanoseconds.

* Parameters:    unsigned int.

* Return Value:    Nothing.

* Minimum time : approx 0.1 microseconds(100 ns)

*/

void adc_delay(unsigned int a)

{

    adcdelaytimer = ADC_timer_Init(NULL);

    timerError = ADC_timer_Enable(adcdelaytimer);

    while(adc_counter < a)

    {

        ;   

    }

    timerError = ADC_timer_Disable(adcdelaytimer);   

    ADC_timer_Disable(adcdelaytimer);

    adc_counter = 0;

}

 

events.c

void ADC_timer_OnCounterRestart(LDD_TUserData *UserDataPtr)

{

  /* Write your code here ... */

    adc_counter++;

}

And i keep getting stuck inside this function:

PE_ISR(ADC_timer_Interrupt)

{

  /* {Default RTOS Adapter} ISR parameter is passed through the global variable */

  ADC_timer_TDeviceDataPtr DeviceDataPrv = INT_FTM0__DEFAULT_RTOS_ISRPARAM;

 

  LDD_TEventMask State = 0U;

 

  if ((FTM_PDD_GetOverflowInterruptFlag(FTM0_BASE_PTR)) != 0U) { /* Is the overflow interrupt flag pending? */

    State |= LDD_TIMERUNIT_ON_COUNTER_RESTART; /* and set mask */

  }

  State &= DeviceDataPrv->EnEvents;    /* Handle only enabled interrupts */

  if (State & LDD_TIMERUNIT_ON_COUNTER_RESTART) { /* Is the overflow interrupt flag pending? */

    FTM_PDD_ClearOverflowInterruptFlag(FTM0_BASE_PTR); /* Clear flag */

    ADC_timer_OnCounterRestart(DeviceDataPrv->UserDataPtr); /* Invoke OnCounterRestart event */

  }

}

 

Any help please....

Outcomes