Teensy 4.0 can do frequency counting, but it's a different processor, so the underlying code is different. Paul did a great job of maintaining pin compatibility, but that doesn't mean that all of the same features are available on all pins. Can you please share (a) your code (see Forum Rule) and (b) your Arduino and TeensyDuino versions?
My code is as follows below. The Arduino version is 1.8.16 and the TeensyDuino version is 1.56.
/* This program is to read the Collins Receiver VFO
* and display it on the LCD. The VFO input read pin is 13.
* This is default in the Teensy 3.6. The VFO frequency is
* combined with the equivalent crystal frequency and IF
* frequency to display to operating frequency on the
* display. The data for crystal frequency has been adjusted
* to 'calibrate' the radio on the normal operating sideband.
*
* 12/01/2018 - Added locking feature where when locked
* one cannot select another band range.
*/
#include <LiquidCrystal.h>
#include <FreqCount.h>
// initialize the LCD with the numbers of the interface pins
LiquidCrystal lcd(2,3,4,5,6,7,8);
unsigned long VFO = 0; //Direct read of the VFO frequency
long Freq = 0; //Used in calculation
char buf[16]; //Array to convert to text
String Afreq; //String for converted text
int x = 0; //Misc variable
//int LockB = 29; //Lock button
//int LockLed = 30; //Lock Led
int LockS = 0; //Status of lock
// The pins the quadrature encoder is connected.
int in_a = 9;
int in_b = 10;
volatile int pulses = 0;
#define LockB 35
#define LockLed 30
//Following is the crystal frequencies for each band.
//Because the frequency count rate for the counter is 100
//instead of one second, one least significant digit is dropped.
//Frequencies can be adjusted so as to calibrate due to crystal age.
long Rfreq[27] = {655635, 675640,695643, 1015625, 1035642, 1315500, 1715348, 1735380, 1795378, 2115500, 2415358, 2435352, 2455350, 2795500, 2995500, 3015500, 3035500, 3055500, 3115287, 3135134, 3155210, 3175500, 3195500, 3215500, 3235500, 3255500, 3275500};
//Following is the bottom frequency range for each of the above
//crystal frequencies.
String Aband[27] = {"3.4","3.6","3.8","7.0","7.2","10.0","14.0","14.2","14.8","18.0","21.0","21.2","21.4","24.8","26.8","27.0","27.2","27.4","28.0","28.2","28.4","28.6","28.8","29.0","29.2","29.4","29.6"};
void count() {
// This function is called by the interrupt
// If in_b is HIGH increment the counter
// otherwise decrement it
if (LockS == 0) { //If LockS is 0 then it's not locked and we can change bands
if (digitalRead(in_b)) {
pulses--;
}
else {
pulses++;
}
if (pulses <0) pulses = 0; //Keep from going negative
if (pulses >26) pulses = 26; //Keep from going to far - 27 band positions - 0 - 26.
}
}
void setup() {
FreqCount.begin(100); //Set the rate for frequency reading. 1000 = 1 second.
// set up the LCD's number of columns and rows:
lcd.begin(16,2);
//configure encoder
pinMode(in_a, INPUT);
pinMode(in_b, INPUT);
//assign interrupt to pin 9 and 'count' to handle the interrupt on a rising pulse from A output (pin 9)
attachInterrupt(digitalPinToInterrupt (9), count, RISING);
Serial.begin(9600);
// configure data pins
pinMode(LockB, INPUT_PULLUP);
pinMode(LockLed, OUTPUT);
LockS = 0; //Start with lock status off
digitalWrite(LockLed, HIGH); //Start with LED off
lcd.print("Collins VFO"); //Sigh on
lcd.setCursor(0,1);
lcd.print("K7NCG 5/8/2018");
delay(1000);
lcd.clear();
}
void loop() {
if (FreqCount.available()) { //See if there is something to read
VFO = FreqCount.read(); //Read it
Calculate(); //Calculate operating frequency
Display(); //Show the results
}
if (digitalRead(LockB) == LOW) { //See if button pressed
delay(50); //Time for bounce
if (digitalRead(LockB) ==LOW) { //If still pressed
while(digitalRead(LockB) == LOW) { } //Wait for button release
if (LockS == 0) {
LockS = 1; //Set locked state
digitalWrite(LockLed,LOW); } //Light LED
else {
if (LockS ==1) {
LockS = 0; //Clear locked state
digitalWrite(LockLed,HIGH); } //Turn off LED
}
}
}
}
void Display() {
lcd.clear();
lcd.setCursor(0,0);
lcd.print(Afreq); //Show the frequency
lcd.setCursor(0,1);
lcd.print("Band: ");
lcd.print(Aband[pulses]); //Show Band Range
}
void Calculate() {
//Calculate the frequency and convert to a printable form
Freq = Rfreq[pulses] - VFO - 45500; //Crystal freq minus VFO minus IF
if (Freq < 1000000) {
ltoa(Freq,buf,10);
Afreq = " ";
Afreq = Afreq + buf[0];
Afreq = Afreq + ".";
Afreq = Afreq + buf[1];
Afreq = Afreq + buf[2];
Afreq = Afreq + buf[3];
Afreq = Afreq + ".";
Afreq = Afreq + buf[4];
Afreq = Afreq + buf[5]; }
else {
ltoa(Freq,buf,10);
Afreq = "";
Afreq = Afreq + buf[0];
Afreq = Afreq + buf[1];
Afreq = Afreq + ".";
Afreq = Afreq + buf[2];
Afreq = Afreq + buf[3];
Afreq = Afreq + buf[4];
Afreq = Afreq + ".";
Afreq = Afreq + buf[5];
Afreq = Afreq + buf[6]; }
}