ERR_MATH while using FreeCntr32 component

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

ERR_MATH while using FreeCntr32 component

跳至解决方案
1,144 次查看
charanreddy
Contributor III

Hi,

I want to find the delay between the raise edge and falling edge of a square wave in KL25Z. so, i am using FreeCntr32 component to calculate that delay but i am getting the ERR_MATH when i tried to read the time using FC321_GetTimeUS(&time) function. Can any one help me with this problem.

Regards,

Charan.

1 解答
779 次查看
marek_neuzil
NXP Employee
NXP Employee

Hello,

The ERR_MATH value is return when the number of us is greater than 0xFFFF (16 bits). You can use GetTimeMS() that return time in ms or GetTimeReal() that return time in a floating point.

In addition, you can also use the Capture_LDD component that allows measurement of the signal between any edges of the signal (one channel of TPM device is used). See the full description of the component in the Help. You can also find a demo example in the discussion thread Capture_LDD SelectCaptureEdge

Best regards,

Marek Neuzil

在原帖中查看解决方案

4 回复数
780 次查看
marek_neuzil
NXP Employee
NXP Employee

Hello,

The ERR_MATH value is return when the number of us is greater than 0xFFFF (16 bits). You can use GetTimeMS() that return time in ms or GetTimeReal() that return time in a floating point.

In addition, you can also use the Capture_LDD component that allows measurement of the signal between any edges of the signal (one channel of TPM device is used). See the full description of the component in the Help. You can also find a demo example in the discussion thread Capture_LDD SelectCaptureEdge

Best regards,

Marek Neuzil

779 次查看
kennyl
Contributor I

Hi Marek, recently, I notice that GetTimeReal() returns the number of clock 'counts' (ticks) rather than the number of seconds. I saw this in KDS 3.0.0 with processor expert, and using KL25Z. Regards, Kenny.

0 项奖励
回复
778 次查看
marek_neuzil
NXP Employee
NXP Employee

Hello,

I am sorry I am not able to reproduce the issue on KL25Z (FreeCntr32 component). The GetTimeReal() method call the RealTimeLdd1_GetTimeReal() method that contains the following code:

LDD_TError RealTimeLdd1_GetTimeReal(LDD_TDeviceData *DeviceDataPtr, LDD_RealTime_Tfloat *TimePtr)

{

  RealTimeLdd1_TDeviceData *DeviceDataPrv = (RealTimeLdd1_TDeviceData *)DeviceDataPtr;

  uint32_t CopyTicks;                  /* Working copy of variable TimerTicks */

  bool CopyOverflow;                   /* Working copy of variable Overflow */

  /* {Default RTOS Adapter} Critical section begin, general PE function is used */

  EnterCritical();

  CopyTicks = DeviceDataPrv->TimerTicks; /* Loading actual number of timer ticks */

  CopyOverflow = DeviceDataPrv->Overflow; /* Loading actual state of "overflow flag" */

  /* {Default RTOS Adapter} Critical section end, general PE function is used */

  ExitCritical();

  if (CopyOverflow) {                  /* Testing counter overflow */

    return ERR_OVERFLOW;               /* If yes then error */

  }

  *TimePtr = (LDD_RealTime_Tfloat)CopyTicks * 0.02499961853F; /* Multiply ticks and clock configuration 0 coefficient */

  return ERR_OK;

}

There is multiplication of ticks by the real-time coefficient. In this case the Resolution of FreeCntr32 is 0.02499961853 s, i.e. every Timer Tick (TimerTicks variable)  represents 24.99961853 ms. It is correct.

If you see any defect in your project sent me the project or steps how to reproduce the issue, please.

Best Regards,

Marek Neuzil

0 项奖励
回复
778 次查看
kennyl
Contributor I

Hi Marek,

Thanks for your time and reply. I have exported my KL25Z project that demonstrates what I'm seeing. Although, I'm not sure how to upload my project onto this forum thread. I do see some kind of upload feature in my freescale account, but the feature is somewhat un-intuitive to use - I can read something about needing to send the uploaded document to a 'place'. I'd just like to upload it here in this thread. If I can upload my zip archive somewhere on this site, then that'd be great too - but not sure how to do it right now.

Any way I can send you my zip archive project? It is for KDS 3.0.0 with Processor Expert.

Thanks Marek. Regards, Kenny.

0 项奖励
回复