Teensy 3.1 and K20 FlexTimer config for FreqMeasure

Status
Not open for further replies.

JBeale

Well-known member
Has anyone done input capture with the full 48 MHz clock resolution (20.8 ns tick) on T3.1 with more than one input signal at the same time? For example, with two channels? Note I'm thinking about two unrelated frequencies, not a 2-channel quadrature encoder output.

I am using the very convenient FreqMeasure library on T3.1 with one channel https://www.pjrc.com/teensy/td_libs_FreqMeasure.html

When reading through FreqMeasureCapture.h
Code:
// Teensy 3.1
#elif defined(__MK20DX256__)
  #define CAPTURE_USE_FTM1_CH0     // FTM1 CH0 is pin 3
  //#define CAPTURE_USE_FTM1_CH1   // FTM1 CH1 is pin 4
  //#define CAPTURE_USE_FTM2_CH0   // FTM2 CH0 is pin 32
  //#define CAPTURE_USE_FTM2_CH1   // FTM2 CH1 is pin 25

it seems there are four possible input pins, going to four distinct timer channels. Later in that file there are four sets of code conditionally compiled depending which of the four input captures is defined. I can only vaguely understand the code so far. Based on fig. 37-175 on page 946 of http://cache.freescale.com/files/32bit/doc/ref_manual/K20P121M100SF2RM.pdf it looks like each of the four possible timer channels has its own CnV capture register and CHnF capture flag.

K20-TimerCompare.jpg
 
Last edited:
Yeah, I've considered making a FreqMeasureMulti library. All the code is there... but the C++ stuff needs to be proper object scope instead of static. The PulsePosition library is probably the best guide of roughly how to restructure the code.
 
Hi,
did you finally manage to allow multiple input signals to be measured in the freqmeasure style ?

best regards

nikos
 
I also am really interested in this - I want to measure 4 wheel speed sensors on a car with my teensy - I need about 1Hz to 5Khz. This library is going to be the best way to achieve that but I'd need 4 pins. I'd have no idea where to start to properly re-factor the library.
 
Status
Not open for further replies.
Back
Top