Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Teensy LC FrequencyMeasure

  1. #1
    Junior Member
    Join Date
    Jul 2018

    Teensy LC FrequencyMeasure

    I'm trying to measure the mark or space of an incoming pulse. No mater what I do I'm only seeing the period. I can not see the high or low width. I poked around in the library and it looks like LC can do mark and space calculation.

    Thanks Ryan

    // PWM to anaolg out  Use DAC output.
    // expect 78 hz input, zero to 100% duy.  0.012820 ms.
    #include <FreqMeasureMulti.h>
    FreqMeasureMulti pwm_in;  // pin 6
    IntervalTimer myTimer;
    unsigned long mark;
    unsigned int val;
    void setup() {
     //pinMode(6, INPUT_PULLUP);
     pinMode(13, OUTPUT);
     digitalWrite(13, HIGH);
    pwm_in.begin(6, FREQMEASUREMULTI_MARK_ONLY);//  Grab mark time.  Sort duty. 
    myTimer.begin(serout, 250000);  //do serial out every 0.25 sec (4 hz).
    void loop() {
      if (pwm_in.available()){
      unsigned long a =;
       mark = pwm_in.countToNanoseconds(a);// micro sec res.
       val = mark / 3130;
    //DAC 0 to 4095 range.
      analogWrite(A12, val);
    void serout(void){
    Serial.println(" ");

  2. #2
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Hi Ryan,
    Reading the Github start page of the FreqMeasureMulti library, it states a capture mode called "FREQMEASUREMULTI_INTERLEAVE".
    If I read that correctly, it measures time between edges [rising or falling].
    Perhaps that is usable for you?


  3. #3
    Junior Member
    Join Date
    Jul 2018
    So.. I re-did my project with a T3.2 and I had the same issue. I ended up uninstalling Arduino IDE and reinstalled with the latest 1.8.13 and Teensystudio. Recompiled the project with T3.2 hardware and now it works as it should. I might revisit the LC later and see if it now works as it should.

    Thanks Ryan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts