Capture frequency_KEAZN16_prcoessor expert

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Capture frequency_KEAZN16_prcoessor expert

1,205 次查看
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 !

标签 (1)
0 项奖励
回复
1 回复

1,108 次查看
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 项奖励
回复