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

Thread: alternative to attachInterrupt() on Teensy 3.6

  1. #1
    Junior Member
    Join Date
    Jan 2020
    Posts
    5

    alternative to attachInterrupt() on Teensy 3.6

    Hello

    Im trying to trigger an ADC read based on a pin changing state using an interrupt.
    After a lot of debugging a bit Ive come to the realization that not even the most basic code using interrupts does not work for me, neither dose the example in the arduino documentation for the attachInterrupt() function.

    For example the code below found on the forums will never execute the statement in the interrupt(I tried supplying a square wave and short pulses). Im not sure if Im missing something or is it possible that this is caused by damage to the board? Are there alternative ways of implementing pin interrupts? I cant run the intervalTimer() either (the interrupt statements dont seem to execute) but using PDB interrupts with the ADC works.


    (https://forum.pjrc.com/threads/24904...=1#post40284):
    Code:
    #define PinInt1 23
    
    void setup() {
      Serial.begin(115200);
      pinMode(PinInt1, INPUT_PULLUP); // sets the digital pin as output
      attachInterrupt(PinInt1, isrService, FALLING); // interrrupt 1 is data ready
    }
    
    void loop()
    {
      delay(1000);
      Serial.println("Running");
    }
    
    // watermark generates this interrupt
    void isrService()
    {
      Serial.println("At ISR0");
    }
    Last edited by Frank B; 02-06-2020 at 07:25 PM. Reason: added code-tags

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,901
    I tried the code, and it works without problems.
    Code:
    pinMode(PinInt1, INPUT_PULLUP); // sets the digital pin as input
    The only potential problem with your code is, that it may work better with INPUT_PULLUP - that depends on the connection to that pin.
    I changed it to INPUT_PULLUP, took a simple wire, connected it to PIn23, and touched GND with the other end.
    Take a look on the printed card, where Pin23 is.
    Last edited by Frank B; 02-06-2020 at 07:24 PM.

Posting Permissions

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