Can I count the number of pulse at 20MHz from a GPIO port with FRDM-K64F?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Can I count the number of pulse at 20MHz from a GPIO port with FRDM-K64F?

ソリューションへジャンプ
2,609件の閲覧回数
alessiopaolucci
Contributor III

Good morning!

For the project of an acquisitor with k64 MCU, can be useful to count the number of adc conversion that I store in a FIFO memory.

The problem is if I can mesure the number of pulse of a 20MHz signal that I have in GPIO input with the port interrupt.

The k64 is setted for 120MHz of core clock and 60MHz of bus clock.

Do you think I can count pulses at this frequency with this micro?

Alessio Paolucci

1 解決策
1,668件の閲覧回数
egoodii
Senior Contributor III

You count the pulses if your pulses feed the FTM 'external clock' input (CLKS = 0b11, and as selected in SOPT4).  The CAPTURE function gives you a way to strobe the beginning and/or end instants that a software interrupt can then read and calculate the difference.  As for speed, I can say that feeding the FTM in quadrature mode I can run up to 66% of the bus-clock speed.  However, the external-clock goes thru an extra 'synchronizer' block in the block-diagram, so I wouldn't be surprised to see that a 60MHz bus-clock is indeed limiting to a 15MHz count rate.

元の投稿で解決策を見る

6 返答(返信)
1,668件の閲覧回数
alessiopaolucci
Contributor III

Thanks! Sorry but maybe I don't understand how works input capture mode.

The FTM go with the bus_clock/prescaler, and when I have the event on the input of a channel save the ftm value on the apposite register. It's right?

How can I count the number of pulse? I need that my pulse frequency is fixed?

0 件の賞賛
返信
1,669件の閲覧回数
egoodii
Senior Contributor III

You count the pulses if your pulses feed the FTM 'external clock' input (CLKS = 0b11, and as selected in SOPT4).  The CAPTURE function gives you a way to strobe the beginning and/or end instants that a software interrupt can then read and calculate the difference.  As for speed, I can say that feeding the FTM in quadrature mode I can run up to 66% of the bus-clock speed.  However, the external-clock goes thru an extra 'synchronizer' block in the block-diagram, so I wouldn't be surprised to see that a 60MHz bus-clock is indeed limiting to a 15MHz count rate.

1,668件の閲覧回数
alessiopaolucci
Contributor III

Thanks Earl, even I thought of feed the timer with the external clock , but unfortunately in the FRDM - K64F this input is not available , then I can do this test only once I have the MCU. If I try this, I will say you if all works.

Best Regards

Alessio

0 件の賞賛
返信
1,668件の閲覧回数
apanecatl
Senior Contributor II

A better choice would be to count the pulses using the input capture function of the Kinetis FlexTimer; it is faster and does not shave processing time for interrupt execution.

1,668件の閲覧回数
alessiopaolucci
Contributor III

Hi Pedro! Thanks for your answers!

I have other questions:

1) In the K64 Sub-Family Reference Manual, I can read:

"Note that the maximum frequency for the channel input signal to be detected correctly is system clock divided by 4, which is required to meet Nyquist criteria for signal sampling."

but the ftm timer go with busclock that is maximum 60MHz like can see from this:


Immagine FlexTimer Clock.png

So I think that I can count maximum 60MHz/4=15MHz, or I can reach 120MHz/4=30MHz?

2) If I have to control at each pulse the number that the ftm timer has reach, I need however to call an interrupt, or I can do in other way?

If I need of the interrupt the advantage of input capture in vanished, or not?

Best Regards!

Alessio

0 件の賞賛
返信
1,668件の閲覧回数
apanecatl
Senior Contributor II

You should be able to count at a max speed of 30MHz (system clk / 4 = 120MHz/4 = 30MHz); I have seen applications running the FTM at 24MHz. You can configure the FTM to generate an overflow interrupt when the count reaches your threshold value if the count is going up, if the ocunt is going down the interrupt could be generated when the count reaches 0.

0 件の賞賛
返信