Capture frequency_KEAZN16_prcoessor expert

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

Capture frequency_KEAZN16_prcoessor expert

1,049 Views
vijenad
Contributor III

for(;;)

  {

   if ((Cap1_GetEventStatus(CapPtr) & LDD_CAPTURE_ON_CAPTURE)!=0U)

     {

       Error = Cap1_GetCaptureValue(CapPtr, &Data);

       current_data = Data;

      

            

       if (current_data > previous_data)

         result = current_data - previous_data;

         previous_data = current_data;

        res_ppg = (result / 6.427977839)*3.814697266;

      

       PPG1_SetRatio16(CapPtr,32767);

      PPG1_SetPeriodUS(CapPtr,res_ppg);

     }

  }

The above code is working fine, Issue is

if there is no input, then res_ppg will have the previous value.

I know - bcoz of  "if ((Cap1_GetEventStatus(CapPtr) & LDD_CAPTURE_ON_CAPTURE)!=0U)",

code doesn't enter into the loop and hence it shows previous freq value.

I tried by providing else loop, but its not working,

Any suggestions !

Labels (1)
0 Kudos
Reply
1 Reply

952 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Vijeendra

If the FTM counter overflows between the first and second capture, I am afraid of the res_ppg will have the wrong value.

I think you can clear those data if FTM counter overflow.

refer below:

     if ((Cap1_GetEventStatus(CapPtr) & LDD_CAPTURE_ON_OVERRUN) != 0U)

     { }

Best Regards

Robin

0 Kudos
Reply