count pulses by FTM channel(S32K148)

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

count pulses by FTM channel(S32K148)

2,873 次查看
ambarish_hundek
Contributor II

Hello Nxp Team,

We are using S32K148 controller in our project.

We have to read the speed information by configuring the FTM module.

controller is manipulating the speed information  in terms of pulses.

controller has to read the  pulses received  through FTM channel.

I used some Example code of S32k148 (input capture code), but I can not find the pulses  count without interrupt configuration.

We can find the frequency and time of the one pulse.

I did not understand the some part of the FTM module in Reference manual.

could you please help me with name the hardware register to read the input pulse count value.

I don't want to configure interrupt(executing ISR for every pulse)  for  Input capture example, it will  waste CPU time.

controller may read  more than 2000 pulses per second .

Kindly help me, Thanks in advance.

Regards,

Ambarish

标签 (1)
标记 (2)
7 回复数

2,423 次查看
dianabatrlova
NXP TechSupport
NXP TechSupport

Hello Ambarish,

The FTM counter clock can be clocked by external clocks from TCLK pins. So, there is a possible route the timer to the TCLK pin.

pastedImage_2.png

Or you can use the PTC29 as GPIO and generate an interrupt on the rising edge.

I hope it helps you.

Best Regards,

Diana

0 项奖励
回复

2,423 次查看
razva_tilimpea
NXP Employee
NXP Employee

Hi,

Please check Quadrature Decoder – Count and Direction Encoding mode.

pastedImage_1.png

In this mode the FTM driver will be driven by your sensor output. The disadvantage is you must use also phase B pin to control counting direction. 

If  you must use only one pin for your application you can switch to LPTMR module which provides pulse counter feature.

In SDK you can find example for LPTMR pulse counter.

Best regards,

Razvan

2,423 次查看
ambarish_hundek
Contributor II

Hello,

Thank you.

do not want check the direction , need to count only pulses(it is for tachy update).

Could you please share me the example code for the pulse counting(FTM channel code).

Yes, we can measure the pulse by LPTMR, but Our hardware(FTM pin is used in Hardware) is using the FTM for pulse counting.

Thank you in advance.

Regards,

Ambarish

0 项奖励
回复

2,423 次查看
razva_tilimpea
NXP Employee
NXP Employee

Hi,

I can develop the example, but you can configure only these pins for quadrature decoder:

pastedImage_1.png

pastedImage_2.pngAlso, is mandatory to use both signals (direction and input signal), so in your case you must connect phase b to high, or to leave it floating with pull up enabled (I'm not sure if the second solution works).

Let me know which FTM pins are used in your application.

Best regards,

Razvan

0 项奖励
回复

2,423 次查看
ambarish_hundek
Contributor II

Hello,

Thanks for quick response.

We are using PTC29 (FTM5, Channel2) for the Speed check.

Regards,

Ambarish.

0 项奖励
回复

2,423 次查看
razva_tilimpea
NXP Employee
NXP Employee

Hi,

In this case you must re-work your hardware :smileysad:. With that pin is impossible to implement the solutions proposed by me and by dianabatrlova

With this hardware you have just to count the edges in software by interrupt handler, but as you already observed the CPU load can be high. 

Best regards,

Razvan

0 项奖励
回复

2,423 次查看
ambarish_hundek
Contributor II

Hello,

Thank you. 

I will update this to hardware team.

Regards,

Ambarish

0 项奖励
回复