Frequency input pin Teensy4

Status
Not open for further replies.

pd0lew

Well-known member
Hi all,

For my Power and SWR meter with frequency range between 1 to 50 MHZ I like to add a frequency counter.

Two questions can I use the same diagram so as attached and witch pin on the Teensy 4 can be used.

Best,
Johan


td_libs_FreqMeasure_sch.gif
 
Be aware that T4 is not 5 volt tolerant.

I used to consider external components for beefing up a low sinsusoid signal, but then discovered the delights of using the internal comparators (in T3 and T4). These are great for very low level signals. You might have a look at this thread for an example of how to code (see #6)... https://forum.pjrc.com/threads/57359-T4-Comparators-and-XBAR?highlight=telephonebill

External components have an advantage of protecting the input, so you may need some protection diodes and a series resistance (in addition to series capacitor for a.c. and mid 3v3 point bias resistors) depending on the threats from external signals.

Get a copy of the iRMXT1060 reference manual and look up page 3425 (Ch 64) for more info.

Edit. By the way, this idea uses the internal DAC voltage reference to compare against your signal input, and that's what switches it up and down.
 
Last edited:
Wow this is a difficult one..... so you use pin 18 as input for your signal right?

Is below still working?

if (FreqCount.available()) {
unsigned long count = FreqCount.read();
Serial.println(count);
}
 
And where is the code below going?
CCM_CCGR2 |= CCM_CCGR2_XBAR1(CCM_CCGR_ON); //turn clock on for xbara1
XBARA1_SEL3 = 0x001C; //This connects XBAR1_OUT6 to XBAR1_IN28 (ACMP3_OUT)
IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_04 = 3; //ALT3 connects XBAR1_INOUT6 to T4 Pin 2
IOMUXC_GPR_GPR6 |= 0b00000000000001000000000000000000; //IOMUXC_XBAR_DIR_SEL_6 = 1 (direction select for XBAR_INOUT6)
CCM_CCGR3 |= 0x03000000; //enable clocks to CG12 of CGR3 for ACMP3
CMP3_CR0 = 0b00000000; //FILTER_CNT=0; HYSTCTR=0
CMP3_CR1 = 0b00010111; //SE=0, high power, COUTA, output pin, enable; mode #2A
CMP3_DACCR = 0b11011111; //Set DAC = 1/2 of VIN2 (3.3v)
CMP3_MUXCR = 0b00000111; //CMP_MUX_PSEL(0) | CMP_MUX_MSEL(7) Input pins select; plus = IN0 (pin 18), minus = DAC (code 7). PSTM = 0 (Pass Through Mode Disabled)
 
Not used "FreqCount" library myself, so maybe someone else can advise about this library. The comparator input signal goes in on Pin 18 and the sq wave output comes out on Pin 2 (and the code would go into Setup).

If you have a T4 at hand and a scope to see the waveforms, have an experiment to see just the comparator in action.

Edit. As a Radio Ham myself, I should emphasize that high power R.F. signals have a nasty habit of invading/inducing wiring, so can do a lot of damage. If you are thinking of building your own Freq Counter make sure you experiment with a low power sig generator first. And when it comes to using in a "harsh" environment, your screening/earthing/isolating will have to be first class.
 
Last edited:
FreqCount library is functional for the T4 and yes it been tested up to about 75Mhz. But as @Telephone Bill pointed out the T4 is not 5v tolerant so you have to make sure your signal is staying at 3.3v.
 
Mike,

Do I need the code then from @Telephone Bill or can I use simple the FreqCount library?

Little confusing ....

I put the code from @Telephone Bill in the setup and can compile without errors.

Pin 18 is in my case used for i2c touchscreen can we use a other pin than 18?

Many questions....

Thanks,
Johan
 
FreqCount library is standalone. You don't need the code from Telephone Bill.

To use frequence count library you can only use Pin 9. All other pins are available.
 
Aha that make sense, I will test this, if I can show my transmitter frequency on the display.

Thanks as always!
 
The frequency count works out of the box, I tested it till 7MHz. Now building a small input circuit with a 74HC14 at 3.3 V

Thanks again Mike.

Johan
 
Not used

Not used "FreqCount" library myself, so maybe someone else can advise about this library. The comparator input signal goes in on Pin 18 and the sq wave output comes out on Pin 2 (and the code would go into Setup).

If you have a T4 at hand and a scope to see the waveforms, have an experiment to see just the comparator in action.

Edit. As a Radio Ham myself, I should emphasize that high power R.F. signals have a nasty habit of invading/inducing wiring, so can do a lot of damage. If you are thinking of building your own Freq Counter make sure you experiment with a low power sig generator first. And when it comes to using in a "harsh" environment, your screening/earthing/isolating will have to be first class.


Please don't respond to questions if you have no knowledge or experience on the subject.
 
Status
Not open for further replies.
Back
Top