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

cancel
Showing results for
Did you mean:
SOLVED

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

1,026 Views
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

Tags (6)
1 Solution
85 Views
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 Replies
85 Views
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?

86 Views
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.

85 Views
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

85 Views
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.

85 Views
Contributor III

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:

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

85 Views
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.