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

Thread: Teensy 3.6: interrupt configured for falling edges fires on both edges

  1. #1
    Junior Member
    Join Date
    May 2017
    Posts
    14

    Teensy 3.6: interrupt configured for falling edges fires on both edges

    I'm working with Teensy 3.6 and I set the interrupt function with the following simple code:
    attachInterrupt(digitalPinToInterrupt(RPM_Pin), RPM_PulseTimeDifference, FALLING);
    I'm using a signal generator to send a square wave to the RPM_Pin, and check it with the oscilloscope. I found that the interrupt on that pin, fires on both the rising and falling edges, as if I had set the interrupt with the CHANGE option instead of FALLING.
    Am I missing some info about the interrupts on Teensy 3.6?

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,376
    That "shouldn't happen", but how do you know it is also triggering on the rising edge?
    Post some demo code.

    Pete

  3. #3
    Junior Member
    Join Date
    May 2017
    Posts
    14
    Quote Originally Posted by el_supremo View Post
    That "shouldn't happen", but how do you know it is also triggering on the rising edge?
    Post some demo code.

    Pete
    I check the time differences with arduino micros function and compare with the oscilloscope's signal

  4. #4
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,376
    I'd still like to see the code you are using to compute the time differences.

    Pete

  5. #5
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,560
    does the tick count from this sketch increase by 1000 each second? (jumper pin 12 to pin 23)
    Code:
    volatile uint32_t ticks;
    
    void ding() {
      ticks++;
    }
    void setup() {
      while (!Serial);
      analogWriteFrequency(23, 1000);    //jumper 23 to 12
      analogWrite(23, 128);
      attachInterrupt(12, ding, FALLING);
    }
    
    void loop() {
      Serial.println(ticks);
      delay(1000);
    }
    try counting ticks with your signal generator.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,279
    I'm running that test here. Indeed it is incrementing 1000 times per second, so only 1 interrupt per cycle.

    Click image for larger version. 

Name:	sc.png 
Views:	3 
Size:	21.8 KB 
ID:	20758

  7. #7
    Junior Member
    Join Date
    May 2017
    Posts
    14
    I found that there is a systematic jitter on the signal; this is why I'm counting two falling fronts instead of one

Posting Permissions

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