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

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

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

Jump to solution
2,071 Views
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 Solution
1,130 Views
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.

View solution in original post

6 Replies
1,130 Views
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 Kudos
1,131 Views
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,130 Views
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 Kudos
1,130 Views
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,130 Views
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 Kudos
1,130 Views
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 Kudos