FreqMeasure Library on the Teensy-LC ?

Status
Not open for further replies.
For complex periodic signals, (analog trumpet sounds) would freqMeasure work?
I've been using fft1024 and peak detection to get my freqs
 
For complex periodic signals, (analog trumpet sounds) would freqMeasure work?

This depends on the circuitry to use to convert the complex analog waveform to a digital signal. If the waveform has strong harmonic content, a simple circuit might turn it into a digital waveform with more than 1 oscillation per cycle of the fundamental tone.

FreqMeasure will measure the frequency you give it on a digital pin. It works quite well for most of the audio range. But it measure the timing between rising edges of a digital signal. To get the results you want, a well designed circuit is needed to turn the analog waveform into the signal for FreqMeasure.
 
Yes, the timers on Teensy LC and 3.2 do support input capture on either or both edges.

Details are in section 31.3.4 starting on page 575.

http://www.pjrc.com/teensy/KL26P121M48SF4RM.pdf

One small caveat on Teensy LC is you must use a special procedure to change the per-channel settings (the "_CnSC" registers). You first need to write a zero to the register, to disable that channel, and wait for the hardware to actually disable it. The wait can be a loop which reads the register back until it's zero, or just a fixed delay will work. One microsecond is plenty if the timer is running from the PLL, as Teensyduino configures it. After the channel is configured to zero, then you can write a new setting.

On Teensy 3.x, you can write any value to the "_CnSC" registers to instantly change to a new configuration, because the timer runs synchronously to the CPU. On Teensy LC, the timers have asynchronous clocking, so they require this extra step. Writing a new setting without first going to zero is ignored by the hardware.
 
Well I imagine that just saved me several hours of debugging after failure to properly read the datasheet. Many thanks !

Dave.
 
Status
Not open for further replies.
Back
Top