I think I've been overthinking this problem--partially because @waynegal didn't post enough code to show what will be done with the measured frequency.
If the frequency is just to be used for a display for the program user, it doesn't need to be update more than 10 times a second. If it will be used to control an antenna tuner, you may need results more often--but probably not more than a few hundred times a second.
To simplify, there's no need to stop the frequency counter after you start it unless you absolutely have to do something else with pin 13. You can just read the value and use it as you wish---store it, display it, use it to control the temperature of your hot tub---whatever! ;-)
Here's the sample code to show how to do that. It worked OK up to the 2MHz limit of my el-cheapo function generator.
(I assume that your hardware presents a clean, near-square-wave signal in the 0 to 3.3V range to pin 13).
Code:
/* **********************************************
* Based on FreqCount - Example with serial output
* http://www.pjrc.com/teensy/td_libs_FreqCount.html
*
* This example code is in the public domain.
*
* Revised to put frequency counting in a function
* You can do anything you want with the return value
* Compiled for TA3.6. Frequency input on pin13 assumed by library
*/
#include <FreqCount.h>
const char compileTime [] = "T3.6 FreqCount Measurement Test Compiled on " __DATE__ " " __TIME__;
void setup() {
Serial.begin(57600);
delay(500);
Serial.println();
Serial.println(compileTime);
FreqCount.begin(1); // count for 1 millisecond
}
uint32_t lastfreq;
void loop() {
uint32_t startmicro;
char ch;
// get frequency with any character received
if(Serial.available()){
ch = Serial.read();
startmicro = micros();
lastfreq = GetFreq() * 1000; //correct for 1mSec counting interval but lose resolution
// Since lastfreq is a global, you can use it anywhere you want in your program.
Serial.printf("F = %lu Call1 took %lu microseconds\n",lastfreq, micros()-startmicro);
// if you call GetFreq again within 1mSec, the routing has to wait for a new value
startmicro = micros();
lastfreq = GetFreq() * 1000; //correct for 1mSec counting interval but lose resolution
Serial.printf("F = %lu Call2 took %lu microseconds\n",lastfreq, micros()-startmicro);
}
}
// This function returns the last read frequency
// If you call it with less than 1 millisecond between
// calls, the function waits for the next valid count
uint32_t GetFreq(void){
while(!FreqCount.available()); // wait until a valid frequency is available
return FreqCount.read(); // this resets the available flag
}